Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/dmd/ctfeexpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,8 @@ bool isCtfeValueValid(Expression newval)
return true; //((StructLiteralExp *)newval)->ownedByCtfe;
if (newval.op == TOK.classReference)
return true;
if (newval.op == TOK.type)
return true;
if (newval.op == TOK.vector)
return true; // vector literal
if (newval.op == TOK.function_)
Expand Down
16 changes: 13 additions & 3 deletions src/dmd/dinterpret.d
Original file line number Diff line number Diff line change
Expand Up @@ -2029,12 +2029,21 @@ public:
{
printf("%s Expression::interpret() '%s' %s\n", e.loc.toChars(), Token.toChars(e.op), e.toChars());
printf("type = %s\n", e.type.toChars());
e.print();
showCtfeExpr(e);
}
e.error("cannot interpret `%s` at compile time", e.toChars());
result = CTFEExp.cantexp;
}

override void visit(TypeExp e)
{
debug (LOG)
{
printf("%s TypeExp.interpret() %s\n", e.loc.toChars(), e.toChars());
}
result = e;
}

override void visit(ThisExp e)
{
debug (LOG)
Expand Down Expand Up @@ -2076,7 +2085,7 @@ public:
}
return;
}
assert(result.op == TOK.structLiteral || result.op == TOK.classReference);
assert(result.op == TOK.structLiteral || result.op == TOK.classReference || result.op == TOK.type);
return;
}
e.error("value of `this` is not known at compile time");
Expand Down Expand Up @@ -5062,7 +5071,8 @@ public:
result = CTFEExp.cantexp;
return;
}
assert(pthis.op == TOK.structLiteral || pthis.op == TOK.classReference);

assert(pthis.op == TOK.structLiteral || pthis.op == TOK.classReference || pthis.op == TOK.type);

if (fd.isVirtual() && !e.directcall)
{
Expand Down
12 changes: 12 additions & 0 deletions test/compilable/test20065.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
alias AliasSeq(T...) = T;

void main()
{
enum string[] array1 = [AliasSeq!("foo")];

static assert(array1 == ["foo"]);

enum string[] array2 = [AliasSeq!()];

static assert(array2 == []);
}
2 changes: 1 addition & 1 deletion test/fail_compilation/fail4206.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail4206.d(9): Error: cannot interpret `s` at compile time
fail_compilation/fail4206.d(9): Error: initializer must be an expression, not `s`
---
*/

Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/fail8262.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* TEST_OUTPUT:
---
fail_compilation/fail8262.d(32): Error: cannot interpret `Tuple8262!1` at compile time
fail_compilation/fail8262.d(32): Error: initializer must be an expression, not `Tuple8262!1`
fail_compilation/fail8262.d(27): Error: template instance `fail8262.T8262!(Tuple8262!1)` error instantiating
fail_compilation/fail8262.d(19): Error: cannot implicitly convert expression `S(0)` of type `S` to `int`
---
Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/ice11919.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice11919.d(17): Error: cannot interpret `foo` at compile time
fail_compilation/ice11919.d(17): Error: initializer must be an expression, not `foo`
fail_compilation/imports/a11919.d(4): Error: template instance `a11919.doBar!(Foo).doBar.zoo!(t)` error instantiating
fail_compilation/imports/a11919.d(11): instantiated from here: `doBar!(Foo)`
fail_compilation/ice11919.d(25): instantiated from here: `doBar!(Bar)`
Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/ice12362.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice12362.d(12): Error: cannot interpret `foo` at compile time
fail_compilation/ice12362.d(12): Error: initializer must be an expression, not `foo`
---
*/

Expand Down