[Issue 23365] New: Throwing the bottom value should be allowed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Sep 24 11:20:55 UTC 2022
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 at puremagic.com
Reporter: Ajieskola at 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.
--
More information about the Digitalmars-d-bugs
mailing list