Bug 8626 – Mixin forward reference semantic run leads to inconsistent AST
Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-09-06T13:52:33Z
Last change time
2023-04-05T12:31:32Z
Assigned to
No Owner
Creator
David Nadlinger
Comments
Comment #0 by code — 2012-09-06T13:52:33Z
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).
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?
Comment #3 by k.hara.pg — 2013-04-06T11:05:35Z
(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...
Comment #4 by razvan.nitu1305 — 2023-04-05T12:31:32Z
This code fails because of a forward reference today: test.d(6): Error: struct `test.Foo7974` no size because of forward reference . It seems that this has been fixed.