https://issues.dlang.org/show_bug.cgi?id=13669
Issue ID: 13669
Summary: [CTFE] Destructor call on static array variable is not
yet supported in CTFE
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: CTFE
Severity: major
Priority: P1
Component: DMD
Assignee: [email protected]
Reporter: [email protected]
Following code should work, but doesn't.
bool test()
{
string dtor;
struct S
{
char x = 'x';
~this() { dtor ~= x; }
}
{ S[2] a; } // line 12
assert(dtor == "xx");
dtor = "";
{ S[2] a = [S('a'), S('b')]; }
assert(dtor == "ab");
return true;
}
static assert(test());
Currently the case outputs weird CTFE error.
test.d(12): Error: static variable typeid(S[2]) cannot be read at compile time
test.d(21): called from here: test()
test.d(21): while evaluating: static assert(test())
--