Skip to content

Commit ee70c63

Browse files
Allow TypeExp during CTFE execution
1 parent 21dcbbd commit ee70c63

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

src/dmd/ctfeexpr.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,6 +1835,8 @@ bool isCtfeValueValid(Expression newval)
18351835
return true; //((StructLiteralExp *)newval)->ownedByCtfe;
18361836
if (newval.op == TOK.classReference)
18371837
return true;
1838+
if (newval.op == TOK.type)
1839+
return true;
18381840
if (newval.op == TOK.vector)
18391841
return true; // vector literal
18401842
if (newval.op == TOK.function_)

src/dmd/dinterpret.d

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,7 +2085,7 @@ public:
20852085
}
20862086
return;
20872087
}
2088-
assert(result.op == TOK.structLiteral || result.op == TOK.classReference);
2088+
assert(result.op == TOK.structLiteral || result.op == TOK.classReference || result.op == TOK.type);
20892089
return;
20902090
}
20912091
e.error("value of `this` is not known at compile time");
@@ -5071,7 +5071,8 @@ public:
50715071
result = CTFEExp.cantexp;
50725072
return;
50735073
}
5074-
assert(pthis.op == TOK.structLiteral || pthis.op == TOK.classReference);
5074+
5075+
assert(pthis.op == TOK.structLiteral || pthis.op == TOK.classReference || pthis.op == TOK.type);
50755076

50765077
if (fd.isVirtual() && !e.directcall)
50775078
{

test/fail_compilation/fail4206.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
TEST_OUTPUT:
33
---
4-
fail_compilation/fail4206.d(9): Error: cannot interpret `s` at compile time
4+
fail_compilation/fail4206.d(9): Error: initializer must be an expression, not `s`
55
---
66
*/
77

test/fail_compilation/ice11919.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
TEST_OUTPUT:
33
---
4-
fail_compilation/ice11919.d(17): Error: cannot interpret `foo` at compile time
4+
fail_compilation/ice11919.d(17): Error: initializer must be an expression, not `foo`
55
fail_compilation/imports/a11919.d(4): Error: template instance `a11919.doBar!(Foo).doBar.zoo!(t)` error instantiating
66
fail_compilation/imports/a11919.d(11): instantiated from here: `doBar!(Foo)`
77
fail_compilation/ice11919.d(25): instantiated from here: `doBar!(Bar)`

test/fail_compilation/ice12362.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
TEST_OUTPUT:
33
---
4-
fail_compilation/ice12362.d(12): Error: cannot interpret `foo` at compile time
4+
fail_compilation/ice12362.d(12): Error: initializer must be an expression, not `foo`
55
---
66
*/
77

0 commit comments

Comments
 (0)