Comment #0 by snarwin+bugzilla — 2022-01-10T03:06:04Z
As of DMD 2.098.1, the following program fails to compile:
---
enum isHashable(T) = __traits(compiles, T.init.tupleof[0][0].sizeof);
struct SumType(Types...)
{
union Storage
{
Types values;
}
Storage storage;
static if (isHashable!(Types[0])) {}
}
string[] toLines(Expression val) {
return [];
}
alias Expression = SumType!(Scope, Return);
struct Return {
Expression* _expr = new Expression;
}
struct Scope {
Expression[] statements;
string[] toLines() {
return Expression.init.toLines;
}
}
---
When attempting to compile, DMD gives the following output:
---
Error: unknown, please file report on issues.dlang.org
---
Any further reduction of the example program either causes compilation to succeed, or results in a different error.
Comment #1 by moonlightsentinel — 2022-01-17T14:54:20Z
Comment #2 by moonlightsentinel — 2022-01-17T15:19:53Z
The actual error message:
---
Error: cannot use non-constant CTFE pointer in an initializer `&SumType(Storage(Scope(null), Return(void)))`
---
Suppressed since https://github.com/dlang/dmd/pull/8583
Comment #3 by robert.schadek — 2024-12-13T19:20:22Z