[Issue 20674] New: [DIP1000] inference of `scope` is easily confused
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 16 02:45:59 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20674
Issue ID: 20674
Summary: [DIP1000] inference of `scope` is easily confused
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: rejects-valid, safe
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: ag0aep6g at gmail.com
This compiles as expected:
----
int* f()(int* p)
{
static int g;
g = 0;
return new int;
}
int* g() @safe
{
int x;
return f(&x);
}
----
This doesn't, but should:
----
int* f()(int* p)
{
static int g;
g = 0;
auto p2 = p; /* the only difference */
return new int;
}
int* g() @safe
{
int x;
return f(&x); /* Error: reference to local variable `x` assigned to
non-scope parameter `p` calling test.f!().f */
}
----
--
More information about the Digitalmars-d-bugs
mailing list