digitalmars.D.bugs - [Issue 19145] New: template alias with same name in function doesn't
- d-bugmail puremagic.com (48/48) Aug 06 2018 https://issues.dlang.org/show_bug.cgi?id=19145
https://issues.dlang.org/show_bug.cgi?id=19145 Issue ID: 19145 Summary: template alias with same name in function doesn't re-instantiate Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: wrong-code Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: schveiguy yahoo.com If I define 2 variables in the same function with the same name using separate scopes, the compiler treats them as the same alias when passing to templates: // using old template style to work with older versions template isInt(alias var) { pragma(msg, "instantiated with " ~ typeof(var).stringof); enum isInt = is(typeof(var) == int); } void main() { { int item; static assert(isInt!item); } { long item; static assert(!isInt!item); // failure all the way back to 2.060 } } The pragma prints only ONCE, and only prints the first type. Just for sanity, I reversed the tests, and it's the same thing: void main() { { long item; static assert(!isInt!item); } { int item; static assert(isInt!item); // fails } } --
Aug 06 2018