CTFE bug?

Simen Kjærås simen.kjaras at gmail.com
Mon Jan 21 12:57:55 UTC 2019


On Monday, 21 January 2019 at 07:31:39 UTC, Simen Kjærås wrote:
> Now, as for why the simple, sensible code in the bug report 
> doesn't work, I have no idea. It seems `new S` marks the block 
> in some way that prevents regular assignment from working.

So I spent a little time looking into this. It seems 
assignToLvalue doesn't know how to deal with structs. I simply 
added this to dinterpret.d, around line 4026 (just before the 
"`%s` cannot be evaluated at compile time" block):

         else if (auto sle = e1.isStructLiteralExp())
         {
             oldval = sle;
         }

Now, is this a sufficient fix? I don't know. Does it break things 
elsewhere? I don't know. Does it work in this specific case, 
solving this specific problem? Sure does.

--
   Simen


More information about the Digitalmars-d mailing list