Bug 19145 – template alias with same name in function doesn't re-instantiate

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-08-06T12:33:49Z
Last change time
2021-04-04T19:19:47Z
Keywords
wrong-code
Assigned to
No Owner
Creator
Steven Schveighoffer

Comments

Comment #0 by schveiguy — 2018-08-06T12:33:49Z
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 } }
Comment #1 by moonlightsentinel — 2021-04-04T19:19:47Z
Fixed in current HEAD