[Issue 20467] New: initializerSemantic() is run multiple times for a single Initializer
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Dec 25 20:22:28 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20467
Issue ID: 20467
Summary: initializerSemantic() is run multiple times for a
single Initializer
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: b2.temp at gmx.com
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).
--
More information about the Digitalmars-d-bugs
mailing list