[Issue 12753] All enum members trait, and missing function return values

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri May 16 03:05:57 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12753

--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to bearophile_hugs from comment #2)
> enum Foo { A, B, C }
> int bar4(immutable Foo x) {
>     final switch (x) with (Foo) {
>         case A: return 0;
>         case B: return 1;
>         case C: return 2;
>     }
> }
> void main() {}
> 
> 
> Here there is no return at the end of the function.

Because it will throw SwitchError in runtime.

void main() { bar4(cast(Foo)99); }

core.exception.SwitchError at test(3): No appropriate switch clause found

--


More information about the Digitalmars-d-bugs mailing list