diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index b15d9a53136047ab9f0ff6128b5108d45e0d6332..5039837d1570686166184ef050c0d0d3fa524063 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -176,6 +176,11 @@ static void HandleNativeAndAsyncMethods(ETSChecker *checker, ir::MethodDefinitio if (util::Helpers::IsAsyncMethod(node)) { if (scriptFunc->ReturnTypeAnnotation() != nullptr) { + if (scriptFunc->Signature() == nullptr) { // #23134 + ES2PANDA_ASSERT(checker->IsAnyError()); + return; + } + auto *asyncFuncReturnType = scriptFunc->Signature()->ReturnType(); if (!asyncFuncReturnType->IsETSObjectType() || diff --git a/ets2panda/test/ast/parser/ets/signature_return_type.ets b/ets2panda/test/ast/parser/ets/signature_return_type.ets new file mode 100644 index 0000000000000000000000000000000000000000..daab0cbfa20176bbf5e863b5a6c6415b32f6a104 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/signature_return_type.ets @@ -0,0 +1,29 @@ +/* + * 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. + */ + +async a => ...delete const { p } = []; + +/* @@? 16:7 Error SyntaxError: 'async' flags must be used for functions only at top-level. */ +/* @@? 16:9 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 16:9 Error SyntaxError: Unexpected token, expected '('. */ +/* @@? 16:12 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 16:12 Error TypeError: The type of parameter 'delete' cannot be inferred */ +/* @@? 16:22 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 16:22 Error SyntaxError: Rest parameter must be the last formal parameter. */ +/* @@? 16:30 Error TypeError: Unresolved reference p */ +/* @@? 16:34 Error SyntaxError: Unexpected token '='. */ +/* @@? 16:34 Error TypeError: Indexed access is not supported for such expression type. */ +/* @@? 16:37 Error SyntaxError: Unexpected token ']'. */ +/* @@? 16:38 Error SyntaxError: Unexpected token, expected ']'. */