Bug 7464 – Better Error Message When Using S.tupleof within S

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-08T08:54:45Z
Last change time
2024-12-13T17:58:20Z
Keywords
accepts-invalid, diagnostic
Assigned to
No Owner
Creator
David Simcha
See also
https://issues.dlang.org/show_bug.cgi?id=7190
Moved to GitHub: dmd#18412 →

Comments

Comment #0 by dsimcha — 2012-02-08T08:54:45Z
struct S { static if(hasIndirections!(typeof(this))) {} } template hasIndirections(T) { enum hasIndirections = hasIndirectionsImpl!(typeof(T.init.tupleof)); } template hasIndirectionsImpl(T...) { static if (!T.length) { enum hasIndirectionsImpl = false; } else { enum hasIndirectionsImpl = true; } } This is wrong because S isn't fully defined yet, so S.init.tupleof makes no sense. However, the error message is extremely obtuse: Error: struct S no size yet for forward reference
Comment #1 by andrej.mitrovich — 2014-04-28T12:14:51Z
The new diagnostic is: ----- test.d(2): Error: forward reference of variable hasIndirections test.d(2): Error: template instance test.hasIndirections!(S) error instantiating ----- But I'm not sure this is better.
Comment #2 by dlang-bugzilla — 2017-07-19T04:54:30Z
FWIW, the code compiled before https://github.com/dlang/dmd/pull/595.
Comment #3 by b2.temp — 2023-02-11T05:01:36Z
compiles since 2.080 but AFAIU this should not
Comment #4 by robert.schadek — 2024-12-13T17:58:20Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18412 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB