must scope for delegates restrict compilation?

Adam D. Ruppe destructionator at gmail.com
Thu Oct 3 12:08:04 UTC 2019


On Thursday, 3 October 2019 at 11:56:55 UTC, Oleg B wrote:
> I think this code must get compilation error, but it didn't, 
> furthermore result program get UB.

Indeed, the spec allows the compiler to issue an error, but 
doesn't require it. tbh it was due to difficulty in implementing 
the compile time error back when it was designed, so Walter kept 
the spec flexible.

If you mark the function as @safe now, you will get a compile 
error on it now. But without that annotation, the compiler keeps 
its older, looser behavior.


More information about the Digitalmars-d-learn mailing list