Bug 13820 – switch and case expressions should support alias this types

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-12-05T00:17:00Z
Last change time
2016-09-18T19:24:38Z
Keywords
pull
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2014-12-05T00:17:08Z
cat > enh.d << CODE struct Foo { int val; alias val this; } void main() { auto foo = Foo(10); switch (foo) { case Foo(5): break; default: break; } } CODE dmd -c enh ---- enh.d(11): Error: 'foo' must be of integral or string type, it is a Foo enh.d(13): Error: case must be a string or an integral constant, not Foo(5) ---- The compiler should attempt to implicitly convert the expressions to an integral or string type.
Comment #1 by mk — 2015-04-26T17:09:12Z
Comment #2 by mk — 2016-09-18T19:24:38Z
Probably fixed by bug 7979 *** This issue has been marked as a duplicate of issue 7979 ***