Thread overview
TypeInfo_Array.value is null
Nov 05, 2020
Remi
Nov 05, 2020
Remi
Nov 05, 2020
kinke
Nov 06, 2020
Remi
November 05, 2020
Hi all,

I've got pretty far implementing a barebones runtime to compile my project to WASM with LDC. However, I've hit a road block where the TypeInfo_Array instance I get has a null "value" member. Here is how I get that TypeInfo instance:

* Access a "int[string]" which calls _aaGetY
* TypeInfo_AssociativeArray ti is passed to _aaGetY
* ti.key is TypeInfo_Aya as expected but ti.key.value is null

I followed how TypeInfo_Array is written in the vanilla runtime object.d and I was expecting TypeInfo_Array.value to be set by the compiler but it is null in my case.

Is there something I should be doing that I'm not?

Thanks,
Remi Gillig.
November 05, 2020
On Thursday, 5 November 2020 at 16:48:50 UTC, Remi wrote:
> Hi all,
>
> I've got pretty far implementing a barebones runtime to compile my project to WASM with LDC. However, I've hit a road block where the TypeInfo_Array instance I get has a null "value" member. Here is how I get that TypeInfo instance:
>
> * Access a "int[string]" which calls _aaGetY
> * TypeInfo_AssociativeArray ti is passed to _aaGetY
> * ti.key is TypeInfo_Aya as expected but ti.key.value is null
>
> I followed how TypeInfo_Array is written in the vanilla runtime object.d and I was expecting TypeInfo_Array.value to be set by the compiler but it is null in my case.
>
> Is there something I should be doing that I'm not?
>
> Thanks,
> Remi Gillig.

Just found that in the online editor, it does the same:

https://run.dlang.io/is/RzUrI5

With LDC or DMD, same result, it prints "null".
November 05, 2020
On Thursday, 5 November 2020 at 16:48:50 UTC, Remi wrote:
> I followed how TypeInfo_Array is written in the vanilla runtime object.d and I was expecting TypeInfo_Array.value to be set by the compiler but it is null in my case.

Hi, typeid(string) is a built-in TypeInfo in druntime (https://github.com/ldc-developers/druntime/blob/412467a452e2d12f561a2eace933dd44014af3c6/src/rt/util/typeinfo.d#L612), not built by the compiler.

> Is there something I should be doing that I'm not?

By the looks of it, you should probably be using the `next()` method instead of the `value` field directly.
November 06, 2020
On Thursday, 5 November 2020 at 19:00:43 UTC, kinke wrote:
> On Thursday, 5 November 2020 at 16:48:50 UTC, Remi wrote:
>> I followed how TypeInfo_Array is written in the vanilla runtime object.d and I was expecting TypeInfo_Array.value to be set by the compiler but it is null in my case.
>
> Hi, typeid(string) is a built-in TypeInfo in druntime (https://github.com/ldc-developers/druntime/blob/412467a452e2d12f561a2eace933dd44014af3c6/src/rt/util/typeinfo.d#L612), not built by the compiler.
>
>> Is there something I should be doing that I'm not?
>
> By the looks of it, you should probably be using the `next()` method instead of the `value` field directly.

Yeah it's kind of how I worked around it, I just needed `value` for `getHash` so I did an override of `getHash` for TypeInfo_Aa which worked. It was still surprising as `next()` returns `value` for TypeInfo_Array even in the D runtime.