digitalmars.D.bugs - [Issue 23124] New: [dip1000] scope and return should not be inferred
- d-bugmail puremagic.com (37/37) May 19 2022 https://issues.dlang.org/show_bug.cgi?id=23124
https://issues.dlang.org/show_bug.cgi?id=23124 Issue ID: 23124 Summary: [dip1000] scope and return should not be inferred for trusted function Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: Ajieskola gmail.com This should compile, but does not. ---------- struct MyType { private system int* _content; // This type is designed so that _content will never point to local data. trusted pure this(return ref int i){_content = new int(i);} // Note, not marked RETURN scope. Should return an unscoped pointer. trusted pure scope content(){return _content;} } safe void main() { int* outer; if(true) { int inner; // Inferred as scope, which is intended auto myVar = MyType(inner); // Should be allowed outer = myVar.content; } } ---------- More through explaination: https://forum.dlang.org/thread/edtbjavjzkwogvutxpho forum.dlang.org --
May 19 2022