Skip to content

Commit

Permalink
fix isArray error (web-devkits#143)
Browse files Browse the repository at this point in the history
Signed-off-by: Su Yihan <[email protected]>
  • Loading branch information
yviansu authored Jan 22, 2024
1 parent c3de8ed commit 355cd3d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/backend/binaryen/lib/init_builtin_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3233,8 +3233,8 @@ function Array_isArray(module: binaryen.Module) {
module.local.get(returnIdx, binaryen.i32),
module.i32.const(0),
),
/** 13 is EXArray tag in quickjs */
module.if(module.i32.eq(is_arr_extref, module.i32.const(13)), setTrue),
/* tag `DynExtRefArray` in runtime library's enum `dyn_type_t` value is 12 */
module.if(module.i32.eq(is_arr_extref, module.i32.const(12)), setTrue),
);
statementArray.push(setDefault);
statementArray.push(is_array);
Expand Down
8 changes: 7 additions & 1 deletion tests/samples/builtin_array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ export function length() {
return aLen;
}

export function isArray() {
export function isArray_anyType() {
const a: any = [1, 2, 3];
const b = Array.isArray(a);
return b;
}

export function isArray_arrayType() {
const a = [1, 2, 3];
const b = Array.isArray(a);
return b;
}
7 changes: 6 additions & 1 deletion tools/validate/wamr/validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,12 @@
"result": "3:f64"
},
{
"name": "isArray",
"name": "isArray_anyType",
"args": [],
"result": "0x1:i32"
},
{
"name": "isArray_arrayType",
"args": [],
"result": "0x1:i32"
}
Expand Down

0 comments on commit 355cd3d

Please sign in to comment.