[Dlang-internal] DIP1000 discussion and testing
Walter Bright via Dlang-internal
dlang-internal at puremagic.com
Sat Dec 17 23:47:40 PST 2016
On 12/17/2016 7:38 AM, Mathias Lang wrote:
> int* escape () @safe
> {
> int i;
> Foo f;
> f.v = &i;
> return f.foo;
> }
>
> struct Foo
> {
> int* v;
> int* foo () @safe { return this.v; }
> }
Rewriting to the equivalent:
```
int* escape() @safe
{
int i;
Foo f;
f.v = &i;
return foo(g); // Error: scope variable f assigned to non-scope
// parameter g calling bug.foo
}
struct Foo
{
int* v;
}
int* foo(ref Foo g) @safe { return g.v; }
```
So the trouble here is dmd not recognizing that f.foo() is the same as foo(f).
More information about the Dlang-internal
mailing list