digitalmars.D.bugs - [Issue 23365] New: Throwing the bottom value should be allowed
- d-bugmail puremagic.com (27/27) Sep 24 2022 https://issues.dlang.org/show_bug.cgi?id=23365
https://issues.dlang.org/show_bug.cgi?id=23365 Issue ID: 23365 Summary: Throwing the bottom value should be allowed Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: Ajieskola gmail.com Compiled with a recent master DMD version, flags -preview=dip1000. ----------------------------- safe void main(){throw *null;} ----------------------------- The above example fails to compile with this: ----------------------------- app.d(1): Error: can only throw class objects derived from `Throwable`, not type `noreturn` ----------------------------- The code example should compile, albeit with a crash at runtime. The bottom type is supposed to convert to any type, including exceptions. It follows that throwing a bottom type should be allowed by the language, resulting in a runtime crash if that code is actually reached. --
Sep 24 2022