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

          Issue ID: 22101
           Summary: Nullable.get(fallback) cannot be used with
                    non-@safe/pure/nothrow types
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: phobos
          Assignee: nob...@puremagic.com
          Reporter: dlang-bugzi...@thecybershadow.net

////// test.d //////
import std.typecons;

struct S
{
    ~this() {}
}

void main()
{
    Nullable!S s;
    s.get(S());
}
////////////////////

Outputs:

.../phobos/std/typecons.d(3091,24): Error: `pure` function
`std.typecons.Nullable!(S).Nullable.get!().get` cannot call impure destructor
`test.S.~this`
.../phobos/std/typecons.d(3091,24): Error: `@safe` function
`std.typecons.Nullable!(S).Nullable.get!().get` cannot call `@system`
destructor `test.S.~this`
test.d(5,2):        `test.S.~this` is declared here
.../phobos/std/typecons.d(3091,24): Error: destructor `test.S.~this` is not
`nothrow`
.../phobos/std/typecons.d(3091,24): Error: `nothrow` function
`std.typecons.Nullable!(S).Nullable.get!().get` may throw
test.d(11,7): Error: template instance
`std.typecons.Nullable!(S).Nullable.get!()` error instantiating

--

Reply via email to