From a42748953d32dd964ee2de6eea009add3063aa54 Mon Sep 17 00:00:00 2001 From: daizihan Date: Thu, 7 Aug 2025 10:51:10 +0800 Subject: [PATCH] Fix fuzz crash Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICRQU6?from=project-issue Signed-off-by: daizihan --- ets2panda/parser/ETSparser.cpp | 4 +++ .../test/runtime/ets/fuzz/empty_ident.ets | 26 +++++++++++++++++++ .../{ => fuzz}/too_many_exclamation_mark.ets | 0 .../runtime/ets/{ => fuzz}/too_many_minus.ets | 0 .../runtime/ets/{ => fuzz}/too_many_plus.ets | 0 .../ets/{ => fuzz}/too_many_plus_1.ets | 0 .../runtime/ets/{ => fuzz}/too_many_tilde.ets | 0 .../srcdumper/srcdumper-ets-ignored.txt | 12 +++++---- 8 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 ets2panda/test/runtime/ets/fuzz/empty_ident.ets rename ets2panda/test/runtime/ets/{ => fuzz}/too_many_exclamation_mark.ets (100%) rename ets2panda/test/runtime/ets/{ => fuzz}/too_many_minus.ets (100%) rename ets2panda/test/runtime/ets/{ => fuzz}/too_many_plus.ets (100%) rename ets2panda/test/runtime/ets/{ => fuzz}/too_many_plus_1.ets (100%) rename ets2panda/test/runtime/ets/{ => fuzz}/too_many_tilde.ets (100%) diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index a3508bb574..3b3d8dee7b 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -2173,6 +2173,10 @@ ir::TSTypeParameter *ETSParser::ParseTypeParameter([[maybe_unused]] TypeAnnotati auto saveLoc = Lexer()->GetToken().Start(); auto *paramIdent = ExpectIdentifier(false, false, *options | TypeAnnotationParsingOptions::REPORT_ERROR); + if (paramIdent == nullptr) { + paramIdent = AllocBrokenExpression(startLoc); + } + ir::TypeNode *constraint = nullptr; if (Lexer()->GetToken().Type() == lexer::TokenType::KEYW_EXTENDS) { Lexer()->NextToken(); diff --git a/ets2panda/test/runtime/ets/fuzz/empty_ident.ets b/ets2panda/test/runtime/ets/fuzz/empty_ident.ets new file mode 100644 index 0000000000..dd74b1f045 --- /dev/null +++ b/ets2panda/test/runtime/ets/fuzz/empty_ident.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. + */ +/*--- + tags: [compile-only, negative] +---*/ + +*/ +class A< { + d: +} + +function B<() { + let a:(A void +} \ No newline at end of file diff --git a/ets2panda/test/runtime/ets/too_many_exclamation_mark.ets b/ets2panda/test/runtime/ets/fuzz/too_many_exclamation_mark.ets similarity index 100% rename from ets2panda/test/runtime/ets/too_many_exclamation_mark.ets rename to ets2panda/test/runtime/ets/fuzz/too_many_exclamation_mark.ets diff --git a/ets2panda/test/runtime/ets/too_many_minus.ets b/ets2panda/test/runtime/ets/fuzz/too_many_minus.ets similarity index 100% rename from ets2panda/test/runtime/ets/too_many_minus.ets rename to ets2panda/test/runtime/ets/fuzz/too_many_minus.ets diff --git a/ets2panda/test/runtime/ets/too_many_plus.ets b/ets2panda/test/runtime/ets/fuzz/too_many_plus.ets similarity index 100% rename from ets2panda/test/runtime/ets/too_many_plus.ets rename to ets2panda/test/runtime/ets/fuzz/too_many_plus.ets diff --git a/ets2panda/test/runtime/ets/too_many_plus_1.ets b/ets2panda/test/runtime/ets/fuzz/too_many_plus_1.ets similarity index 100% rename from ets2panda/test/runtime/ets/too_many_plus_1.ets rename to ets2panda/test/runtime/ets/fuzz/too_many_plus_1.ets diff --git a/ets2panda/test/runtime/ets/too_many_tilde.ets b/ets2panda/test/runtime/ets/fuzz/too_many_tilde.ets similarity index 100% rename from ets2panda/test/runtime/ets/too_many_tilde.ets rename to ets2panda/test/runtime/ets/fuzz/too_many_tilde.ets diff --git a/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt b/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt index c032ed173d..c1df249e62 100644 --- a/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt +++ b/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt @@ -40,17 +40,19 @@ runtime/ets/type_param_in_union.ets runtime/ets/StringFasta.ets runtime/ets/struct-identifier.ets runtime/ets/struct-init2.ets -runtime/ets/too_many_minus.ets -runtime/ets/too_many_plus.ets -runtime/ets/too_many_plus_1.ets -runtime/ets/too_many_tilde.ets -runtime/ets/too_many_exclamation_mark.ets +runtime/ets/fuzz/too_many_minus.ets +runtime/ets/fuzz/too_many_plus.ets +runtime/ets/fuzz/too_many_plus_1.ets +runtime/ets/fuzz/too_many_tilde.ets +runtime/ets/fuzz/too_many_exclamation_mark.ets +runtime/ets/fuzz/too_many_call_expr.ets runtime/ets/fuzz/too_many_async.ets runtime/ets/fuzz/too_many_await.ets runtime/ets/fuzz/too_many_call_expr.ets runtime/ets/fuzz/too_many_left_brace.ets runtime/ets/fuzz/too_many_left_square_brackets.ets runtime/ets/fuzz/too_many_new_expr.ets +runtime/ets/fuzz/empty_ident.ets runtime/ets/too_many_token.ets ast/compiler/ets/DeclareIndexerTest.ets ast/parser/ets/import_tests/import_class_with_static_field/import_class_with_static_field.ets -- Gitee