https://issues.dlang.org/show_bug.cgi?id=23124
--- Comment #4 from Ate Eskola <[email protected]> --- (In reply to Ate Eskola from comment #3) > Example in my last comment was wrong. Posting a corrected one: > > ---------------- > struct MyType > { private int* wontEverPointToLocal; > int* mayPointToLocalIfScope; > // Safe in the future compiler because > // not callable with scope MyType. > // Dangerous in DMD because it infers > // scope for this reference. > @trusted fun(bool cond){return cond? wontEverPointToLocal: > mayPointToLocalIfScope;} > } > ---------------- Nope, still not right. My brains are porridge. Third try: --------------------- struct MyType { int* ptr; // Safe in DMD because return scope is inferred. // Dangerous in our future compiler because // may return an unscoped pointer to local data, // when MyType is scope. @trusted scope getPtr(bool cond){return cond? ptr: null;} } --------------------- --
