[Issue 5832] New: Template alias parameters are never successfully pattern matched

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 10 16:05:40 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5832

           Summary: Template alias parameters are never successfully
                    pattern matched
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: code at klickverbot.at


--- Comment #0 from klickverbot <code at klickverbot.at> 2011-04-10 16:01:57 PDT ---
The following snippet compiles with latest DMD 2 (0219a5f), but does not behave
as expected:
---
struct Bar(alias v) {}
template isBar(T) {
    static if (is(T _ : Bar!(v), alias v)) {
        enum isBar = true;
    } else {
        enum isBar = false;
    }
}

pragma(msg, isBar!(Bar!1234)); // prints false
---

According to the spec, the second parameter to the is() expression is a
TemplateParameterList, and indeed using a TemplateAliasParameter compiles, but
the type is never matched, i.e. the expression always yields false.

The same phenomenon also occurs when trying to use a specialized template:
---
struct Bar(alias v) {}
template isBar(T) {
    enum isBar = false;
}
template isBar(T : Bar!(v), alias v) {
    enum isBar = true;
}
pragma(msg, isBar!(Bar!1234)); // prints false
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list