digitalmars.D.bugs - [Issue 1308] New: Recursive alias declaration, Error: forward reference to foo
- d-bugmail puremagic.com (42/42) Jul 02 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1308
- d-bugmail puremagic.com (21/21) Sep 27 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1308
- BCS (3/31) Sep 27 2007 int is the default that DMD uses when it don't known what to make of som...
http://d.puremagic.com/issues/show_bug.cgi?id=1308 Summary: Recursive alias declaration, Error: forward reference to foo Product: D Version: 1.017 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: onlystupidspamhere yahoo.se Code: Version 1: template r(alias S, T...) { static if (T.length) alias r!(r, T[1..$]) r; else alias int r; } alias r!(r, Object) foo; Version 2: template f() {} template r(alias S, T...) { static if (T.length) alias r!(r, T[1..$]) r; else alias f r; } alias r!(f, Object) foo; Compiler output: aliasbug.d(3): alias aliasbug.r!(r,Object).r recursive alias declaration aliasbug.d(3): Error: forward reference to 'r!(r,T[1 .. __dollar])' aliasbug.d(3): template instance r!(int) does not match any template declaration aliasbug.d(8): template instance aliasbug.r!(r,Object) error instantiating ---- I'm not sure if the first one should work (it's a minimal case that triggers the error msg), but the latter one should. It's derived from a compile time map template. --
Jul 02 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1308 ------- Comment #1 from onlystupidspamhere yahoo.se 2007-09-27 19:12 ------- The original was a bit messy so here's a bit shorter one: template r(alias S, T...) { static if (T.length) alias r!(r) r; else alias float r; } alias r!(r, r) foo; --- I expect it to work this way: 1. "alias r!(r, r) foo" calls r!(r, r) 2. static if is true so "template r!(r, r)" calls r!(r) 3. static if is now false so "template r!(r)" returns float. 4. r!(r, r) returns r!(r) = float. 5. foo becomes an alias of r!(r, r) = r!(r) = float. --- The "template instance r!(int) does not match any template declaration" doesn't make any sense. There's no instantion of r!(int) happening anywhere. --
Sep 27 2007
Reply to d-bugmail puremagic.com,http://d.puremagic.com/issues/show_bug.cgi?id=1308 ------- Comment #1 from onlystupidspamhere yahoo.se 2007-09-27 19:12 ------- The original was a bit messy so here's a bit shorter one: template r(alias S, T...) { static if (T.length) alias r!(r) r; else alias float r; } alias r!(r, r) foo; --- I expect it to work this way: 1. "alias r!(r, r) foo" calls r!(r, r) 2. static if is true so "template r!(r, r)" calls r!(r) 3. static if is now false so "template r!(r)" returns float. 4. r!(r, r) returns r!(r) = float. 5. foo becomes an alias of r!(r, r) = r!(r) = float. --- The "template instance r!(int) does not match any template declaration" doesn't make any sense. There's no instantion of r!(int) happening anywhere.int is the default that DMD uses when it don't known what to make of somthing. If it were up to me I'd have an unknown_type to server for this.
Sep 27 2007