Two problems with json and lcd

AlphaPurned Alpha at Beta.com
Wed Feb 19 08:14:34 UTC 2020


On Tuesday, 18 February 2020 at 22:00:25 UTC, Petar Kirov 
[ZombineDev] wrote:
> On Tuesday, 18 February 2020 at 18:05:43 UTC, AlphaPurned wrote:
>> json has two issues, it doesn't work with tuple:
>>
>> (isArray!T)
>>
>> goes to
>>
>> (isArray!T || (T.stringof.length > 4 && T.stringof[0..5] == 
>> "Tuple"))
>>
>> and right below
>>
>>         else
>>         {
>>             static assert(false, text(`unable to convert type 
>> "`, T.Stringof, `" to json`));
>>         }
>>
>> and it used Stringof.
>>
>>
>>
>> This fixes json to work with tuples.
>>
>> Second, LCD gives me the error:
>>
>> error : function `Test.main.rate!(d, "", "").rate` cannot 
>> access frame of function `Test.main.__foreachbody1`
>>
>> Not sure the problem, works fine with DMD. I'm simply 
>> accessing a variable outside a templated function.
>
> I didn't understand your first point, but if I got the gist of 
> your second one, the difference may be due to LDC not yet 
> having implemented this:
> https://github.com/ldc-developers/ldc/issues/3125

Probably.

The first is std.json. It is broke. Doesn't work with tuples. The 
change above fixes it by treating tuple as an array(same code). 
It works fine.


More information about the Digitalmars-d-learn mailing list