[Issue 24574] New: Scope not inferred on this parameter
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu May 30 13:27:38 UTC 2024
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: nobody at puremagic.com
Reporter: zopsicle at 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.
--
More information about the Digitalmars-d-bugs
mailing list