Bug 5832 – Template alias parameters are never successfully pattern matched

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2011-04-10T16:01:00Z
Last change time
2012-11-10T10:24:06Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2011-04-10T16:01:57Z
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 ---
Comment #1 by k.hara.pg — 2012-11-09T07:43:59Z
Comment #2 by github-bugzilla — 2012-11-10T03:06:53Z
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 Merge pull request #1275 from 9rnsr/fix5832 Issue 5832 - Template alias parameters are never successfully pattern matched