static assert({
TypeInfo xxx = typeid(Object);
TypeInfo yyy = typeid(new Error("xxx"));
return true;
}());
The first typeid gives:
bug.d(7): Error: Cannot interpret & D17TypeInfo_C6Object6__initZ at compile time
The second one gives:
bug.d(38): Error: dereference of invalid pointer 'Error("xxx",null,0u,null,null,null)'
This code now raises an ICE:
struct S { }
static assert(typeid(S).init.length > 0);
Assertion failure: 'thisval && thisval->op == TOKclassreference' on line 4067 in file 'interpret.c'
If you use a class instead:
class C {}
static assert(typeid(C).init.length > 0);
imp.d(2): Error: static assert (& D16TypeInfo_C3imp1C6__initZ.init.length > 0u) is not evaluatable at compile time
Comment #4 by nilsbossung — 2015-02-04T12:00:58Z
(In reply to Rainer Schuetze from comment #3)
> struct S { }
> static assert(typeid(S).init.length > 0);
Now gives: "Error: static variable typeid(S) cannot be read at compile time".
Same error when trying to call typeid(object.Object).opEquals:
---
static assert(typeid(new Object).opEquals(typeid(new Object)));
---
Error: static variable typeid(object.Object) cannot be read at compile time
---
This blocks 7151.
> class C {}
> static assert(typeid(C).init.length > 0);
Now gives: "Error: typeid(test.C).init is not yet implemented at compile time".
Comment #5 by robert.schadek — 2024-12-13T17:57:14Z