Bug 20467 – initializerSemantic() is run multiple times for a single Initializer

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-12-25T20:22:28Z
Last change time
2024-12-13T19:06:36Z
Assigned to
No Owner
Creator
basile-z
Moved to GitHub: dmd#19652 →

Comments

Comment #0 by b2.temp — 2019-12-25T20:22:28Z
If you add a flag to dmd.init.Initializer and set this flag when initializerSemantic() is run you'll notice that the same Initializer instance will go through initializerSemantic() several times. conveniancy patch to highlight the problem: --- diff --git a/src/dmd/init.d b/src/dmd/init.d index e2e690899..9f5d61b09 100644 --- a/src/dmd/init.d +++ b/src/dmd/init.d @@ -55,6 +55,7 @@ extern (C++) class Initializer : ASTNode { Loc loc; InitKind kind; + bool semaDone; extern (D) this(const ref Loc loc, InitKind kind) diff --git a/src/dmd/initsem.d b/src/dmd/initsem.d index 728932377..16bdb7b56 100644 --- a/src/dmd/initsem.d +++ b/src/dmd/initsem.d @@ -92,6 +92,17 @@ Lno: */ extern(C++) Initializer initializerSemantic(Initializer init, Scope* sc, Type t, NeedInterpret needInterpret) { + + assert(init); + if (init.semaDone) + { + printf("init sema for `%s` already done\n", init.toChars()); + return init; + } + + scope(exit) + init.semaDone = true; + Initializer visitVoid(VoidInitializer i) { i.type = t; --- The test suite passes when using the flag to return earlier (although dmd.dsymbol.PASS would be more appropriated... in case someone wants to make a PR).
Comment #1 by robert.schadek — 2024-12-13T19:06:36Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19652 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB