[Issue 1308] Recursive alias declaration, Error: forward reference to foo

BCS ao at pathlink.com
Thu Sep 27 17:35:57 PDT 2007


Reply to d-bugmail at puremagic.com,

> http://d.puremagic.com/issues/show_bug.cgi?id=1308
> 
> ------- Comment #1 from onlystupidspamhere at 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.




More information about the Digitalmars-d-bugs mailing list