Fix Bugzilla 24602 - Internal compiler error: failed to detect static initialization of associative array

This commit is contained in:
Dennis Korpel 2024-06-17 20:30:26 +02:00 committed by The Dlang Bot
parent 76d8696a14
commit 3e92cca51d
2 changed files with 34 additions and 0 deletions

View file

@ -888,4 +888,11 @@ private extern(C++) final class StaticAAVisitor : SemanticTimeTransitiveVisitor
aaExp.lowering = loweredExp;
}
// https://issues.dlang.org/show_bug.cgi?id=24602
// TODO: Is this intionally not visited by SemanticTimeTransitiveVisitor?
override void visit(ClassReferenceExp crExp)
{
this.visit(crExp.value);
}
}

View file

@ -181,6 +181,32 @@ void testStaticArray()
/////////////////////////////////////////////
// https://issues.dlang.org/show_bug.cgi?id=24602
class Set
{
bool[string] aa;
this(bool[string] aa)
{
this.aa = aa;
}
}
class Bar
{
Set x = new Set(["a": 1, "b": 0]);
}
void testClassLiteral()
{
assert(new Bar().x.aa["a"] == 1);
assert(new Bar().x.aa["b"] == 0);
}
/////////////////////////////////////////////
void main()
{
testSimple();
@ -192,4 +218,5 @@ void main()
testLocalStatic();
testEnumInit();
testStaticArray();
testClassLiteral();
}