Bug 930 – Templates inside templates used as mixins

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-02-04T01:13:44Z
Last change time
2019-07-18T00:16:51Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
Bill Baxter

Comments

Comment #0 by wbaxter — 2007-02-04T01:13:44Z
The following should work I believe, but apparently the type from the outer template does not get propagated to the inner template. It does work if the 'T' line is removed. ---- template ATemplate(T) { template ATemplate() { void foo() { T x = 2; // this line causes an error printf("Hi\n"); } } } class TheClass(alias MixIt) { mixin MixIt; } void main() { auto val = new TheClass!(ATemplate!(int)); val.foo(); }
Comment #1 by wbaxter — 2007-02-04T02:51:41Z
Addendum - At least for my purposes, it turns out this can be handled by using templated static structs instead of mixins: struct ATemplate(T) { static: T svar = 99; void foo() { T x = 2; // this line causes an error printf("Hi\n"); } } class TheClass(MixIt) { MixIt mix; } void main() { auto val = new TheClass!(ATemplate!(int)); val.mix.foo(); } ---- This isn't holding me up in any way now, so downgrading to minor.
Comment #2 by dlang-bot — 2019-07-17T13:44:12Z
@RazvanN7 created dlang/dmd pull request #10192 "Fix Issue 930 - Templates inside templates used as mixins" fixing this issue: - Fix Issue 930 - Templates inside templates used as mixins https://github.com/dlang/dmd/pull/10192
Comment #3 by dlang-bot — 2019-07-18T00:16:51Z
dlang/dmd pull request #10192 "Fix Issue 930 - Templates inside templates used as mixins" was merged into stable: - 40d6c402062e12b417ccd0d1c8bdea128cc43818 by RazvanN7: Fix Issue 930 - Templates inside templates used as mixins https://github.com/dlang/dmd/pull/10192