www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Is live attribute working yet?

reply elfstone <elfstone yeah.net> writes:
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);
     }
Apr 24 2022
next sibling parent reply Tejas <notrealemail gmail.com> writes:
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
Apr 24 2022
parent elfstone <elfstone yeah.net> writes:
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".
Apr 24 2022
prev sibling parent reply Paolo Invernizzi <paolo.invernizzi gmail.com> writes:
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
Apr 24 2022
parent reply elfstone <elfstone yeah.net> writes:
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.
Apr 24 2022
parent Paolo Invernizzi <paolo.invernizzi gmail.com> writes:
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
Apr 24 2022