Skip to content

Commit

Permalink
fix bug of any boxed obj as return value (web-devkits#155)
Browse files Browse the repository at this point in the history
Signed-off-by: Su Yihan <[email protected]>
  • Loading branch information
yviansu authored Apr 16, 2024
1 parent bef9fcf commit 93fbb2e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/backend/binaryen/wasm_expr_gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4639,7 +4639,11 @@ export class WASMExpressionGen {
createDynObjOps.push(
this.module.local.get(tmpVar.index, tmpVar.type),
);
castedValueRef = this.module.block(null, createDynObjOps);
castedValueRef = this.module.block(
null,
createDynObjOps,
tmpVar.type,
);
}
return castedValueRef;
}
Expand Down
13 changes: 13 additions & 0 deletions tests/samples/any_box_obj_as_return_value.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/

function getAnyObj(): any {
return { a: 1 };
}

export function getObjPropFromReturnValue() {
const obj: any = getAnyObj();
console.log(obj.a);
}
10 changes: 10 additions & 0 deletions tools/validate/wamr/validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@
}
]
},
{
"module": "any_box_obj_as_return_value",
"entries": [
{
"name": "getObjPropFromReturnValue",
"args": [],
"result": "1"
}
]
},
{
"module": "any_box_string",
"entries": [
Expand Down

0 comments on commit 93fbb2e

Please sign in to comment.