[Issue 13820] New: switch and case expressions should support alias this types
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Dec 4 16:17:08 PST 2014
https://issues.dlang.org/show_bug.cgi?id=13820
Issue ID: 13820
Summary: switch and case expressions should support alias this
types
Product: D
Version: unspecified
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: code at dawg.eu
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.
--
More information about the Digitalmars-d-bugs
mailing list