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

          Issue ID: 24574
           Summary: Scope not inferred on this parameter
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: zopsi...@use.startmail.com

Consider the following example:

-----
// REQUIRED_ARGS: -preview=dip1000 -preview=dip1021

struct A
{
    void* p;
    @safe nothrow pure void f();
} 

@safe nothrow pure void g(ref A);

@safe void e(ref scope A a)
{
    a.f();  // (1)
    g(a);   // (2)
}
-----

Call (1) fails to compile with:

    scope variable `a` calling non-scope member function `A.f()`

despite A.f being nothrow pure.

Call (2) succeeds to compile because nothrow pure implies scope on the argument
to g.

This discrepancy requires explicitly annotating non-static nothrow pure struct
methods as scope.

--

Reply via email to