www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5832] New: Template alias parameters are never successfully pattern matched

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: code klickverbot.at



---
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: -------
Apr 10 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5832


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid



https://github.com/D-Programming-Language/dmd/pull/1275

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 09 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5832




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/02704fdefa7539838a1441404e3e04f26d2c131f
fix Issue 5832 - Template alias parameters are never successfully pattern
matched

https://github.com/D-Programming-Language/dmd/commit/d71edf8c1a0e986361a89aa006359ed59d3c6db4


Issue 5832 - Template alias parameters are never successfully pattern matched

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 10 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5832


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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