diff --git a/src/backend/binaryen/wasm_expr_gen.ts b/src/backend/binaryen/wasm_expr_gen.ts index e893952..fdaa63d 100644 --- a/src/backend/binaryen/wasm_expr_gen.ts +++ b/src/backend/binaryen/wasm_expr_gen.ts @@ -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; } diff --git a/tests/samples/any_box_obj_as_return_value.ts b/tests/samples/any_box_obj_as_return_value.ts new file mode 100644 index 0000000..08eb528 --- /dev/null +++ b/tests/samples/any_box_obj_as_return_value.ts @@ -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); +} diff --git a/tools/validate/wamr/validation.json b/tools/validate/wamr/validation.json index cbfcd57..5cb1cf7 100644 --- a/tools/validate/wamr/validation.json +++ b/tools/validate/wamr/validation.json @@ -179,6 +179,16 @@ } ] }, + { + "module": "any_box_obj_as_return_value", + "entries": [ + { + "name": "getObjPropFromReturnValue", + "args": [], + "result": "1" + } + ] + }, { "module": "any_box_string", "entries": [