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

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