[Dlang-internal] DIP1000 discussion and testing

Mathias Lang via Dlang-internal dlang-internal at puremagic.com
Sun Dec 18 08:23:28 PST 2016


On Sunday, 18 December 2016 at 15:24:34 UTC, Walter Bright wrote:
>
>> Moreover, this code is obviously correct to the reader:
>>
>> ```
>> struct Foo
>> {
>>     int* v;
>>     int foo () @safe { return *v; }
>> }
>> ```
>>
>> But won't compile. I tried with static arrays just to be sure, 
>> same outcome.
>
> It compiles when I try it.

I didn't meant as a standalone example, but in the context of the 
previous snippet. Full code:

```
int bar () @safe
{
     int i = 42;
     Foo f;
     f.v = &i;
     return f.foo(); // Doesn't compile
}

struct Foo
{
     int* v;
     int foo () @safe { return *v; }
}
```


More information about the Dlang-internal mailing list