Bug 7426 – Inner struct "no size yet for forward reference" when using .tupleof inside it.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-02T12:06:00Z
Last change time
2012-02-08T08:49:24Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
kennytm

Comments

Comment #0 by kennytm — 2012-02-02T12:06:40Z
Test case: ------------------ struct S7426 { static struct Inner { int x; alias typeof(Inner.tupleof) T; } } ------------------ Compile with 'dmd -c test7426.d', expecting to pass silently, but fails with: test7426.d(4): Error: struct test7426.S7426.Inner no size yet for forward reference The regression is introduced in commit f2635c912999f819f6f99f46373a768df7f5abfa when fixing bug 7190.
Comment #1 by kennytm — 2012-02-05T00:47:28Z
Comment #2 by dsimcha — 2012-02-05T20:13:36Z
Probably related test case: struct S { static if(hasIndirections!(typeof(this))) {} } template hasIndirections(T) { enum hasIndirections = hasIndirectionsImpl!(T.tupleof); } template hasIndirectionsImpl(T...) { static if (!T.length) { enum hasIndirectionsImpl = false; } else { enum hasIndirectionsImpl = true; } }
Comment #3 by kennytm — 2012-02-05T23:45:05Z
(In reply to comment #2) > Probably related test case: > > struct S { > static if(hasIndirections!(typeof(this))) {} > } > > template hasIndirections(T) > { > enum hasIndirections = hasIndirectionsImpl!(T.tupleof); > } > > template hasIndirectionsImpl(T...) > { > static if (!T.length) > { > enum hasIndirectionsImpl = false; > } > else > { > enum hasIndirectionsImpl = true; > } > } Pull #696 removed the 'no size yet for forward reference' in this test case, but DMD will complain 'template instance test.hasIndirectionsImpl!(tuple()) error instantiating' anyway.
Comment #4 by github-bugzilla — 2012-02-06T19:37:15Z
Comment #5 by bugzilla — 2012-02-06T19:38:15Z
This isn't a regression, it never really did work right. But the partial fix at least makes it work correctly for the original bug report. It may not be completely fixable.
Comment #6 by dsimcha — 2012-02-06T19:47:50Z
Still broken with my test case. Where do we draw the line between regressions and non-regressions? 2.058 has a lot of borderline cases where internal changes in the compiler make pre-existing bugs affect code they didn't used to affect.
Comment #7 by dsimcha — 2012-02-08T08:49:24Z
(In reply to comment #6) > Still broken with my test case. Where do we draw the line between regressions > and non-regressions? 2.058 has a lot of borderline cases where internal > changes in the compiler make pre-existing bugs affect code they didn't used to > affect. From discussion on the Phobos newsgroup, my test case shouldn't work because X.tupleof shouldn't be defined, if X is not fully defined yet. I'll close this bug report as fixed but start a new one requesting a decent error message so it's clearer that this is why it doesn't work.