[Issue 23928] New: improve error msg: scope variable s assigned to non-scope parameter this calling abc

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 19 06:59:51 UTC 2023


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

          Issue ID: 23928
           Summary: improve error msg: scope variable s assigned to
                    non-scope parameter this calling abc
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at digitalmars.com

The code:

struct S {
    int* p;
    void abc(int i) @safe { }
}

void test() @safe {
    int i;
    S s;
    s.p = &i;
    s.abc(1);
}

compiled with -preview=dip1000 produces the message:

test.d(13): Error: scope variable `s` assigned to non-scope parameter `this`
calling `abc`

A better message would be:

Error: scope variable `s` calling non-scope member function `abc`

--


More information about the Digitalmars-d-bugs mailing list