diff --git a/ets2panda/compiler/core/ETSCompiler.cpp b/ets2panda/compiler/core/ETSCompiler.cpp index 798ec10abff49a3d9d3c353f566e61936261fce9..8992e4463266032d54ade146aee52b4d6f28f6a7 100644 --- a/ets2panda/compiler/core/ETSCompiler.cpp +++ b/ets2panda/compiler/core/ETSCompiler.cpp @@ -815,6 +815,7 @@ void ETSCompiler::Compile(const ir::Identifier *expr) const ETSGen *etsg = GetETSGen(); auto const *smartType = expr->TsType(); + ES2PANDA_ASSERT(smartType != nullptr); if (smartType->IsETSTypeParameter() || smartType->IsETSPartialTypeParameter() || smartType->IsETSNonNullishType()) { smartType = etsg->Checker()->GetApparentType(smartType); } diff --git a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp index 0c4e4caf52f4d93e039341ad5d7fcbb1173d3042..4bdc0ff953a0817b4c9bfbb3c7a6bf4d27c0cc5a 100644 --- a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp +++ b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp @@ -228,6 +228,7 @@ static void ProcessCalleeMethodBody(ir::AstNode *body, checker::ETSChecker *chec auto *id = node->AsIdentifier(); if (auto ref = varMap.find(id->Variable()); ref != varMap.end()) { id->SetVariable(ref->second); + id->Check(checker); } } if (substitution == nullptr) { diff --git a/ets2panda/test/ast/compiler/ets/LambdaParameterWithImplicitType.ets b/ets2panda/test/ast/compiler/ets/LambdaParameterWithImplicitType.ets new file mode 100644 index 0000000000000000000000000000000000000000..2cde0dd68986def9af9d335f874e106fcd582d0b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/LambdaParameterWithImplicitType.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const foo = async (): Promise => { + return 42.0; // Return a double to satisfy the Promise +}; + +foo().then((result) => { // crash - issue #26815 + console.log(`Async function returned: ${result}`); +}); + +let fooArray = ["a", "b", "c"]; +let fooArrayMapped = fooArray.map(x => x + " is mapped"); // crash - issue #26856 +let fooArrayMappedAndChecked = fooArray.map(x => x == "a"); // crash - issue #26856