www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19650] New: static foreach eponymous template only has one

https://issues.dlang.org/show_bug.cgi?id=19650

          Issue ID: 19650
           Summary: static foreach eponymous template only has one
                    implementation
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: atila.neves gmail.com

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.

--
Feb 05