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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 2 12:14:50 PDT 2007


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 at digitalmars.com
        ReportedBy: onlystupidspamhere at 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.


-- 



More information about the Digitalmars-d-bugs mailing list