Thread overview
[Issue 8626] New: Mixin forward reference semantic run leads to inconsistent AST
Sep 06, 2012
klickverbot
Apr 06, 2013
Kenji Hara
Apr 06, 2013
David Nadlinger
Apr 06, 2013
Kenji Hara
September 06, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8626

           Summary: Mixin forward reference semantic run leads to
                    inconsistent AST
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: code@klickverbot.at


--- Comment #0 from klickverbot <code@klickverbot.at> 2012-09-06 13:52:33 PDT ---
See the discussion at http://forum.dlang.org/thread/CAP9J_HV9YLEkwsFD=e3YT2Juxr0=Kb6sxJNnc2UP4Tr1qmz4+w@mail.gmail.com, this bug is just to make sure the issue doesn't get lost.

---
mixin template mix7974() {
 uint _x;
}

struct Foo7974 {
 immutable fa = Foo7974(0);

 this(uint x) {
   _x = x;
 }
 mixin mix7974!();
}
---

To recapitulate, the issue in the snippet is that the full semantic pass for mix7974, including the arrayCopy() of its members to the surrounding scope, is run twice at two separate points in time. Some parts of the resulting AST reference the _x declaration from the first run, and some that from the second.

Looking at TemplateMixin::semantic, this behavior seems to be somewhat intended, but the outcome is a bug, as Walter confirmed (and a major problem for LDC codegen).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 06, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8626



--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-04-06 10:33:56 PDT ---
To: David Nadlinger

Is this the problem that you had explained in the forum recently? If so, it is correctly asserted in dmd source code now.

StructDeclaration::semantic https://github.com/D-Programming-Language/dmd/pull/1760

ClassDeclaration::semantic and InterfaceDeclaration::semantic https://github.com/D-Programming-Language/dmd/pull/1822

Therefore, can I mark this "RESOLVED FIXED"?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 06, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8626



--- Comment #2 from David Nadlinger <code@klickverbot.at> 2013-04-06 10:52:21 PDT ---
No, this is a much earlier, distinct bug report. However, it is likely related in terms of the root cause, so it might be fixed just as well. I suppose I have to re-enable the 7494 test case on LDC to see if it passes – which commits to I need to back-port to 2.062?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 06, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8626



--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2013-04-06 11:05:35 PDT ---
(In reply to comment #2)
> No, this is a much earlier, distinct bug report. However, it is likely related in terms of the root cause, so it might be fixed just as well. I suppose I have to re-enable the 7494 test case on LDC to see if it passes – which commits to I need to back-port to 2.062?

At least #1760 would be necessary. But, other many forward reference bugs fixed in 2.063 may be related to it . So I'm worried about the possibility that the back-port does not work...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------