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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 27 17:12:42 PDT 2007


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.


-- 



More information about the Digitalmars-d-bugs mailing list