Thread overview
Is @live attribute working yet?
Apr 24, 2022
elfstone
Apr 24, 2022
Tejas
Apr 24, 2022
elfstone
Apr 24, 2022
Paolo Invernizzi
Apr 24, 2022
elfstone
Apr 24, 2022
Paolo Invernizzi
April 24, 2022

Dub(DMD 2.099.1) builds and runs the following code without a warning.

import std.stdio;
import core.stdc.stdlib;

@live
void test()
{
    int* p = cast(int*) malloc(32);
    p = cast(int*) malloc(32);
    free(p);
}

void main()
{
    test();
    writeln("???");
}

Isn't it supposed to trigger an error according to the doc (https://dlang.org/spec/ob.html)?

@live void test()
{
    auto p = allocate();
    p = allocate(); // error: p was not disposed of
    release(p);
}
April 24, 2022

On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:

>

Dub(DMD 2.099.1) builds and runs the following code without a warning.

import std.stdio;
import core.stdc.stdlib;

@live
void test()
{
    int* p = cast(int*) malloc(32);
    p = cast(int*) malloc(32);
    free(p);
}

void main()
{
    test();
    writeln("???");
}

Isn't it supposed to trigger an error according to the doc (https://dlang.org/spec/ob.html)?

@live void test()
{
    auto p = allocate();
    p = allocate(); // error: p was not disposed of
    release(p);
}

It's development is stalled 😞

https://forum.dlang.org/post/dvbqnlpqainnbtmbuyhl@forum.dlang.org

April 24, 2022
On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:
> Dub(DMD 2.099.1) builds and runs the following code without a warning.
>
>     import std.stdio;
>     import core.stdc.stdlib;
>
>     @live
>     void test()
>     {
>         int* p = cast(int*) malloc(32);
>         p = cast(int*) malloc(32);
>         free(p);
>     }
>
>     void main()
>     {
>         test();
>         writeln("???");
>     }
>
> Isn't it supposed to trigger an error according to the doc (https://dlang.org/spec/ob.html)?
>
>     @live void test()
>     {
>         auto p = allocate();
>         p = allocate(); // error: p was not disposed of
>         release(p);
>     }

You need to use the flag `-preview=dip1021`

  test.d(8,30): Error: variable `test.test.p` assigning to Owner without disposing of owned value
April 24, 2022

On Sunday, 24 April 2022 at 11:07:43 UTC, Tejas wrote:

>

On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:

>

Dub(DMD 2.099.1) builds and runs the following code without a warning.

import std.stdio;
import core.stdc.stdlib;

@live
void test()
{
    int* p = cast(int*) malloc(32);
    p = cast(int*) malloc(32);
    free(p);
}

void main()
{
    test();
    writeln("???");
}

Isn't it supposed to trigger an error according to the doc (https://dlang.org/spec/ob.html)?

@live void test()
{
    auto p = allocate();
    p = allocate(); // error: p was not disposed of
    release(p);
}

It's development is stalled 😞

https://forum.dlang.org/post/dvbqnlpqainnbtmbuyhl@forum.dlang.org

Thanks a lot. I guess I should have taken the "Experimental, Subject to Change" seriously. Still the doc really should be more accurate, like "Just the Idea/To Be Implemented".

April 24, 2022
On Sunday, 24 April 2022 at 11:36:29 UTC, Paolo Invernizzi wrote:
> On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:
>>     [...]
>
> You need to use the flag `-preview=dip1021`
>
>   test.d(8,30): Error: variable `test.test.p` assigning to Owner without disposing of owned value

Weird, it's still not working here. I have tried the flag with dub, and dmd.
April 24, 2022
On Sunday, 24 April 2022 at 12:21:29 UTC, elfstone wrote:
> On Sunday, 24 April 2022 at 11:36:29 UTC, Paolo Invernizzi wrote:
>> On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:
>>>     [...]
>>
>> You need to use the flag `-preview=dip1021`
>>
>>   test.d(8,30): Error: variable `test.test.p` assigning to Owner without disposing of owned value
>
> Weird, it's still not working here. I have tried the flag with dub, and dmd.

You are right with 2.099.1, it seems to be included in the 2.100.0-beta.1 ...

  pinver@Moria test % /Users/pinver/dlang/dmd-2.099.1/osx/bin/dmd -preview=dip1021 -c -o- src/test.d
  pinver@Moria test % /Users/pinver/dlang/dmd-2.100.0-beta.1/osx/bin/dmd -preview=dip1021 -c -o- src/test.d
  src/test.d(8): Error: variable `test.test.p` assigning to Owner without disposing of owned value