[Issue 19371] Taking address of ref return in @safe code: compile-time checks fail

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 10 21:15:55 UTC 2018


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

--- Comment #2 from Stanislav Blinov <stanislav.blinov at gmail.com> ---
Thanks for the pointers about __traits(compiles), I somehow lost the
distinction of braces. However, the point about is(typeof()) still stands
though:

    pragma(msg, typeof(() @safe { return &get(); }));

will print _error_.

In other words:

```
void main() @safe {
    int x;
    ref int get() { return x; }
    // since this doesn't compile:
    int* getExplicit() @safe { return &get(); }
    // ...then it has no type, therefore this should pass:
    static assert(!is(typeof(() @safe { return &get(); })));
}
```

--


More information about the Digitalmars-d-bugs mailing list