digitalmars.D.bugs - [Issue 18146] New: A case expression of final switch allows to pass
- d-bugmail puremagic.com (48/48) Dec 30 2017 https://issues.dlang.org/show_bug.cgi?id=18146
https://issues.dlang.org/show_bug.cgi?id=18146 Issue ID: 18146 Summary: A case expression of final switch allows to pass wrong enum value Product: D Version: D2 Hardware: x86_64 URL: http://dlang.org/phobos/ OS: Linux Status: NEW Severity: normal Priority: P3 Component: dmd Assignee: nobody puremagic.com Reporter: kohei-coco jcom.home.ne.jp This issue relates enum and final switch. The situation is shown roughly below. An enum `Hoge' is defined in file `/foo/bar.d'. --- enum Hoge: ubyte{Val0, Val1, Val2, Val3, Val4} --- Then, other file `/foo/baz.d' imports `bar.d'. template tmp(T){ class Abcd{...} class Efgh(uint tv0, uint tv1, Hoge typ){ safe pure nothrow nogc{ this(){...} this(in T[] wxyz){ static if( tv0 == tv1 ){ final switch(typ){ case Hoge.Val2: static assert(typ == Hoge.Val2); // <- this expression throws an assert exception! // then, `typ' is equal to Hoge.Val1 break; case Hoge.Val1: ...; break; . . . } } // End of `static if' statement } // End of a constructor } } // End of class } // End of template --
Dec 30 2017