digitalmars.D.bugs - [Issue 22384] New: castSwitch confused by noreturn handlers
- d-bugmail puremagic.com (37/37) Oct 13 2021 https://issues.dlang.org/show_bug.cgi?id=22384
https://issues.dlang.org/show_bug.cgi?id=22384 Issue ID: 22384 Summary: castSwitch confused by noreturn handlers Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: moonlightsentinel disroot.org castSwitch allows handlers that neither return a value nor throw an exception - as long as no other handler returns a value. This breaks when passing noreturn handlers, causing castSwitch to throw an exception for the void handlers that don't trow an exception and hence being inferred as noreturn. Example void main() { static void objectSkip(Object) {} static void defaultSkip() {} static noreturn objectError(Object) { assert(false); } static noreturn defaultError() { assert(false); } { alias test = castSwitch!(objectSkip, defaultError); static assert(is(ReturnType!test == void)); // fails, noreturn }{ alias test = castSwitch!(objectError, defaultSkip); static assert(is(ReturnType!test == void)); // fails, noreturn }{ alias test = castSwitch!(objectError, defaultError); static assert(is(ReturnType!test == noreturn)); // valid } } --
Oct 13 2021