diff --git a/ets2panda/compiler/lowering/ets/unboxLowering.cpp b/ets2panda/compiler/lowering/ets/unboxLowering.cpp index 29e8d1f3755d9963f3bca943197a53a019fe4372..7c5570d7aa03baf4c309eaaddd55b7938f9ca519 100644 --- a/ets2panda/compiler/lowering/ets/unboxLowering.cpp +++ b/ets2panda/compiler/lowering/ets/unboxLowering.cpp @@ -753,9 +753,11 @@ struct UnboxVisitor : public ir::visitor::EmptyAstVisitor { break; } } - ES2PANDA_ASSERT(nearestScriptFunction != nullptr); - retStmt->SetArgument(AdjustType(uctx_, retStmt->Argument(), nearestScriptFunction->Signature()->ReturnType())); + if (nearestScriptFunction != nullptr && retStmt != nullptr) { + retStmt->SetArgument( + AdjustType(uctx_, retStmt->Argument(), nearestScriptFunction->Signature()->ReturnType())); + } } void VisitIfStatement(ir::IfStatement *ifStmt) override diff --git a/ets2panda/test/tsconfig/test-decl/typecheck-decl/expected.json b/ets2panda/test/tsconfig/test-decl/typecheck-decl/expected.json index 49f23180a3e6a7c6ac3421a36a9a1d2dfb3be958..c11295340f2ad403bac9b1a921451118c5e12ebc 100644 --- a/ets2panda/test/tsconfig/test-decl/typecheck-decl/expected.json +++ b/ets2panda/test/tsconfig/test-decl/typecheck-decl/expected.json @@ -1,5 +1,5 @@ { "returncode": 1, - "stdout": "TypeError: Type 'int' is not compatible with type 'String' at property 'location' [main.ets:19:28]\nTypeError: Bad operand type, the types of the operands must be numeric, same enumeration, or boolean type. [main.ets:21:9]\n", + "stdout": "TypeError: Type 'Int' is not compatible with type 'String' at property 'location' [main.ets:19:28]\nTypeError: Operator '!=' cannot be applied to types 'String' and 'Int'. [main.ets:21:9]\n", "stderr": "" } \ No newline at end of file