Skip to content

Commit

Permalink
Fix Bugzilla 24807 - Error message missing parens for template instan…
Browse files Browse the repository at this point in the history
…ce (#17015)
  • Loading branch information
ntrel authored Oct 20, 2024
1 parent 58e4136 commit 941a6e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dmd/hdrgen.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions compiler/test/fail_compilation/template_enum_param.d
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 941a6e6

Please sign in to comment.