Fix Bugzilla 24807 - Error message missing parens for template instance (#17015)

This commit is contained in:
Nick Treleaven 2024-10-20 05:19:09 +01:00 committed by GitHub
parent 58e4136f47
commit 941a6e62ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View file

@ -3796,7 +3796,8 @@ private void tiargsToBuffer(TemplateInstance ti, ref OutBuffer buf, ref HdrGenSt
}
else if (Expression e = isExpression(oarg))
{
if (e.op == EXP.int64 || e.op == EXP.float64 || e.op == EXP.null_ || e.op == EXP.string_ || e.op == EXP.this_)
if (!(e.type && e.type.isTypeEnum()) && e.op == EXP.int64 || e.op == EXP.float64 ||
e.op == EXP.null_ || e.op == EXP.string_ || e.op == EXP.this_)
{
toCBuffer(e, buf, hgs);
return;

View file

@ -0,0 +1,17 @@
/*
TEST_OUTPUT:
---
fail_compilation/template_enum_param.d(15): Error: static assert: `false` is false
fail_compilation/template_enum_param.d(17): instantiated from here: `X!(E.a)`
---
*/
enum E
{
a,b,c
}
template X(E e)
{
static assert(false);
}
alias Y = X!(E.a);