[Issue 3924] nothrow ignored in some situations

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 3 03:28:24 UTC 2019


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

Nicholas Wilson <iamthewilsonator at hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |iamthewilsonator at hotmail.co
                   |                            |m
         Resolution|---                         |WORKSFORME

--- Comment #3 from Nicholas Wilson <iamthewilsonator at hotmail.com> ---
Examples given no longer compile:

void main() {
    nothrow void delegate() c = { throw new Exception(""); };
    c();
}

gives

onlineapp.d(2): Error: cannot implicitly convert expression __lambda1 of type
void delegate() pure @safe to void delegate() nothrow
onlineapp.d(2): Error: cannot implicitly convert expression __lambda1 of type
void delegate() pure @safe to void delegate() nothrow

nothrow auto foo() {
    throw new Exception("");
}
void main() {
    foo();
}

gives

onlineapp.d(2): Error: object.Exception is thrown but not caught
onlineapp.d(1): Error: nothrow function onlineapp.foo may throw

nothrow auto foo() {
    auto c = { throw new Exception(""); };
    c();
}
void main() {
    foo();
}

onlineapp.d(3): Error: c is not nothrow
onlineapp.d(1): Error: nothrow function onlineapp.foo may throw

--


More information about the Digitalmars-d-bugs mailing list