D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7721 - Nested template loses context when mixin'd
Summary: Nested template loses context when mixin'd
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-18 05:01 UTC by Simen Kjaeraas
Modified: 2020-02-07 12:30 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Simen Kjaeraas 2012-03-18 05:01:50 UTC
module baz;

template Foo(alias T) {
    mixin T.Baz!();
}

template Bar(U) {
    template Baz( ) {
        U n;
    }
}

void main( ) {
    mixin Foo!(Bar!int);
}

Yields the error messages:

baz.d(9): Error: undefined identifier U, did you mean variable n?
baz.d(4): Error: mixin baz.main.Foo!(__T3BarTiZ).Baz!() error instantiating
baz.d(14): Error: mixin baz.main.Foo!(__T3BarTiZ) error instantiating
Comment 1 Simen Kjaeraas 2018-02-13 09:02:01 UTC
Simplified example showing template template parameters are unnecessary to trigger this bug:

template Bar(T) {
    template Baz() {
        T n;
    }
}

unittest {
    // Works.
    Bar!int.Baz!().n = 3;
    // Fails: foo.d(3): Error: undefined identifier T
    mixin Bar!int.Baz!();
}
Comment 2 Simen Kjaeraas 2020-02-07 12:30:57 UTC
Fixed in 2.087.1.