https://issues.dlang.org/show_bug.cgi?id=19371
--- Comment #3 from Nick Treleaven <n...@geany.org> --- (In reply to Stanislav Blinov from comment #2) > pragma(msg, typeof(() @safe { return &get(); })); > > will print _error_. What compiler are you using? With run.dlang.io the above (currently) prints: int* delegate() pure nothrow @nogc @safe It's the same even if I remove the @safe attribute, safety inference (or safe consistency checking) is not happening inside typeof alone. BTW if I do this: auto f = { return &get(); }; pragma(msg, typeof(f)); I get `int* delegate() pure nothrow @nogc @system`. The compiler does safety inference for `f` before typeof(f) is analysed. The same happens if I replace the literal with `{ return cast(int*)7; }`, it's reported as @safe inside pragma(msg, typeof(...)), but @system when assigning it to a variable `f` and doing pragma(msg, typeof(f)). > // 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(); }))); It depends if `typeof` is supposed to do @safe checking, or if it is just a tool to extract a type from an expression (that appears to have a valid type), even if that expression might not actually compile with full compiler checks. I think it's the latter, which is why __traits(compiles) was invented. --