digitalmars.D.bugs - [Issue 3510] New: Cannot forward reference a templated type from within a template mixin
- d-bugmail puremagic.com Nov 14 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3510 Summary: Cannot forward reference a templated type from within a template mixin Product: D Version: 1.051 Platform: All OS/Version: All Status: NEW Keywords: rejects-valid Severity: blocker Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: matti.niemenmaa+dbugzilla iki.fi Blocks: 340 --- Comment #0 from Matti Niemenmaa <matti.niemenmaa+dbugzilla iki.fi> 2009-11-14 12:30:29 PST --- Simple case: struct S(int x) {} template Mix() { Sa s; } class C { mixin Mix!(); alias S!(0) Sa; } foo.d(2): Error: forward reference to 'S!(0)' foo.d(2): Error: Sa is used as a type foo.d(2): Error: variable foo.C.Mix!().s voids have no value foo.d(5): Error: mixin foo.C.Mix!() error instantiating Move the mixin of Mix!() below the alias of S!() and it compiles. For the following code, that move alone isn't enough: template Tuple(T...) { alias T Tuple; } struct S(size_t x) {} template Mix() { Sa s; } class C { mixin Mix!(); alias Tuple!("foo") T; alias S!(T.length) Sa; } [same errors as above] Moving the mixin below the alias of S!() gives: foo.d(8): Error: identifier 'length' of 'T.length' is not defined foo.d(8): Error: template instance S!(int) does not match template declaration S(uint x) foo.d(4): Error: template instance S!(int) is used as a type foo.d(4): Error: variable foo.C.Mix!().s voids have no value foo.d(9): Error: mixin foo.C.Mix!() error instantiating After moving the mixin, the code can still be made to compile by introducing a constant to hold the length. The following class C works: alias Tuple!("foo") T; const size_t Tlength = T.length; alias S!(Tlength) Sa; mixin Mix!(); Unfortunately, in my case T depends on Mix in ways the compiler can't figure out without having Mix mixed in before T (Bug 3509), so this is a blocker for me. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 14 2009








d-bugmail puremagic.com