[Dlang-internal] -dip1000 discussion
Walter Bright via Dlang-internal
dlang-internal at puremagic.com
Sun Jan 29 14:13:03 PST 2017
On 1/29/2017 4:10 AM, Olivier FAURE wrote:
> On Sunday, 29 January 2017 at 11:45:30 UTC, Walter Bright wrote:
>> On 1/29/2017 3:24 AM, Olivier FAURE wrote:
>> It's best to post compilable code fragments. This code compiles with -dip1000:
>
> It shouldn't. This is one of the 'gotcha's that I mentioned earlier.
>
> struct Container
> {
> int* ptr;
> }
>
> ref Container store(ref return scope Container c, return scope int* ptr) @safe
> {
> c.ptr = ptr; // Error: scope variable ptr assigned to c with longer lifetime
> return c;
> }
I made a mistake, I had forgotten to add @safe to store(). With that, the
example I posted does not compile, and neither does the expanded one here, with
the error message I added in.
More information about the Dlang-internal
mailing list