[Issue 23364] New: returning bottom type by ref should work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Sep 24 11:19:27 UTC 2022


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

          Issue ID: 23364
           Summary: returning bottom type by ref should work
           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 and -run

-----------------------------
@safe ref foo(return ref noreturn arg){return arg;}
@safe void main()
{ foo(*null);
}
-----------------------------

The above example crashes at runtime with the following message:

-----------------------------
core.exception.AssertError at app.d(1): Accessed expression of type `noreturn`
----------------
??:? _d_assert_msg [0x43a7c8]
??:? pure nothrow ref @nogc @safe noreturn app.foo(return ref noreturn)
[0x43a730]
??:? _Dmain [0x43a73e]
-----------------------------

The example should run without any error, because `foo` function does not
actually take or return the bottom value - only a (null) reference to one. It's
the same reason why this program runs without error:

-----------------------------
@safe ref foo(return ref int arg){return arg;}
@safe void main()
{ foo(*cast(int*)null);
}
-----------------------------

--


More information about the Digitalmars-d-bugs mailing list