[Issue 23933] New: auto return type disables DIP1000 scope check

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 24 09:18:10 UTC 2023


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

          Issue ID: 23933
           Summary: auto return type disables DIP1000 scope check
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: atila.neves at gmail.com

This fails to compile with -preview=dip1000:

---------------
struct Struct {
    int* p;
    void hmm(int i) @safe { }
}

void safeUsage() @safe {
    int i;
    scope s = Struct();
    s.hmm(42);
}
---------------
bug.d(9): Error: scope variable `s` assigned to non-scope parameter `this`
calling `hmm`



But changing `hmm`'s return type to `auto` makes the error go away.

--


More information about the Digitalmars-d-bugs mailing list