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

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7464 - Better Error Message When Using S.tupleof within S
Summary: Better Error Message When Using S.tupleof within S
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid, diagnostic
Depends on:
Blocks:
Reported: 2012年02月08日 08:54 UTC by David Simcha
Modified: 2024年12月13日 17:58 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2012年02月08日 08:54:45 UTC
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 Andrej Mitrovic 2014年04月28日 12:14:51 UTC
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 Vladimir Panteleev 2017年07月19日 04:54:30 UTC
FWIW, the code compiled before https://github.com/dlang/dmd/pull/595.
Comment 3 basile-z 2023年02月11日 05:01:36 UTC
compiles since 2.080 but AFAIU this should not
Comment 4 dlangBugzillaToGithub 2024年12月13日 17:58:20 UTC
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


AltStyle によって変換されたページ (->オリジナル) /