www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - newCTFE Status Feburary 2019

reply Stefan Koch <uplink.coder googlemail.com> writes:
Hi Guys,

I've just fixed interactions between structures and delegates.

making the following code work:

struct S2
{
   int x = 64;
   int[2] a;
}

S2 fn2()
{
     S2 s = S2.init;

     void initS()
     {
         s.x = 1;
         s.a[0] = 2;
         s.a[1] = 3;
     }

     initS();
     return s;
}


static assert(fn2() == S2(1, [2, 3]));


--
There are still a few bugs to be fixed however.
One being broadcast assignment within the nested function.
if you were to write s.a = 2, that should result in s.a == [2,2].
However currently newCTFE will drop that assignment when 
referring to to an outer variable
from within a nested function.

Technically this should not be too hard to fix, but currently I 
can't put my finger on the cause ....
Feb 05 2019
parent reply Stefan Koch <uplink.coder googlemail.com> writes:
On Tuesday, 5 February 2019 at 22:51:04 UTC, Stefan Koch wrote:
 Hi Guys,

 Technically this should not be too hard to fix, but currently I 
 can't put my finger on the cause ....
Fixed. The cause was a misplaced return which would skip the store of the created temporary array :p Sometimes it can be so simple. Broadcast array assignment works reliably now.
Feb 05 2019
parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Tue, Feb 05, 2019 at 11:08:02PM +0000, Stefan Koch via Digitalmars-d wrote:
 On Tuesday, 5 February 2019 at 22:51:04 UTC, Stefan Koch wrote:
 Hi Guys,
 
 Technically this should not be too hard to fix, but currently I
 can't put my finger on the cause ....
Fixed. The cause was a misplaced return which would skip the store of the created temporary array :p Sometimes it can be so simple. Broadcast array assignment works reliably now.
Awesome. Can't wait for newCTFE to land in master... still looking forward... T -- "I'm running Windows '98." "Yes." "My computer isn't working now." "Yes, you already said that." -- User-Friendly
Feb 05 2019