Bug 19650 – static foreach eponymous template only has one implementation

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-02-05T18:45:09Z
Last change time
2021-04-04T19:13:48Z
Assigned to
No Owner
Creator
Atila Neves

Comments

Comment #0 by atila.neves — 2019-02-05T18:45:09Z
This code: ------------------ import std.meta; void main() { func!(double, int, double); } void func(A...)() { static foreach(Type; A) {{ enum isType(T) = is(T == Type); alias filtered = Filter!(isType, A); pragma(msg, "Type: ", Type, " filtered: ", filtered); }} } ------------------ Should print: Type: double filtered: (double, double) Type: int filtered: (int) Type: double filtered: (double, double) However, it prints this instead: Type: double filtered: (double, double) Type: int filtered: (double, double) Type: double filtered: (double, double) This is especially egregious since not using a double brace causes the compiler to complain that `isType` has already been defined. The double braces make the error go away but only the first implementation is used.
Comment #1 by moonlightsentinel — 2021-04-04T19:13:48Z
Current master prints: Type: double filtered: (double, double) Type: int filtered: (int) Type: double filtered: (double, double)