You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an Array<ref_extern> is declared and used, the compiler generates an error due to ref_extern not being compatible with the alignof function. This will trigger three compiler errors and a warning related to size, my guess would be because the size of a ref_extern is not fully defined somewhere?
I'm not sure if this is intended, but it seems like a viable option to have an Array with external references (e.g. host maintained objects). This might also affect other types and classes.
Steps to reproduce
Use the following code:
declare function external_function(): ref_extern;
let external_ref = external_function();
let broken_array:Array<ref_extern> = [];
broken_array.push(external_ref);
The last line of code will trigger a number of errors and warnings:
ERROR AS203: Operation 'alignof' cannot be applied to type 'ref_extern'.
:
209 │ ensureCapacity(changetype<usize>(this), len, alignof<T>());
│ ~
└─ in ~lib/array.ts(209,58)
WARNING AS201: Conversion from type 'usize' to 'u32' will require an explicit cast when switching between 32/64-bit.
:
209 │ ensureCapacity(changetype<usize>(this), len, alignof<T>());
│ ~~~~~~~~~~~~
└─ in ~lib/array.ts(209,50)
ERROR AS203: Operation 'alignof' cannot be applied to type 'ref_extern'.
:
214 │ store<T>(this.dataStart + (<usize>oldLen << alignof<T>()), value);
│ ~
└─ in ~lib/array.ts(214,59)
ERROR AS203: Operation 'store' cannot be applied to type 'ref_extern'.
:
214 │ store<T>(this.dataStart + (<usize>oldLen << alignof<T>()), value);
│ ~
└─ in ~lib/array.ts(214,13)
FAILURE 3 compile error(s)
AssemblyScript version
0.27.6
The text was updated successfully, but these errors were encountered:
externrefs can't be stored in linear memory so having an array of them doesn't make much sense. You could have a table of externrefs which would function like an array, but I'm not sure if assemblyscript provides direct access to tables.
Bug description
If an
Array<ref_extern>
is declared and used, the compiler generates an error due toref_extern
not being compatible with thealignof
function. This will trigger three compiler errors and a warning related to size, my guess would be because the size of aref_extern
is not fully defined somewhere?I'm not sure if this is intended, but it seems like a viable option to have an Array with external references (e.g. host maintained objects). This might also affect other types and classes.
Steps to reproduce
Use the following code:
The last line of code will trigger a number of errors and warnings:
AssemblyScript version
0.27.6
The text was updated successfully, but these errors were encountered: