diff --git a/ets2panda/parser/ETSparserClasses.cpp b/ets2panda/parser/ETSparserClasses.cpp index 5b48649542721955d09afc7368a88ad5a5da3ed3..a1dbeeea650d4a50365802b3ef214eb93e067b9a 100644 --- a/ets2panda/parser/ETSparserClasses.cpp +++ b/ets2panda/parser/ETSparserClasses.cpp @@ -223,6 +223,9 @@ std::tuple ETSParser::ParseClassMemberAccessModif accessFlag = ir::ModifierFlags::INTERNAL_PROTECTED; break; } + case lexer::TokenType::EOS: { // process invalid tokenType + return {ir::ModifierFlags::NONE, false, false}; + } default: { ES2PANDA_UNREACHABLE(); } diff --git a/ets2panda/test/ast/compiler/ets/invalid_access_modifier.ets b/ets2panda/test/ast/compiler/ets/invalid_access_modifier.ets new file mode 100644 index 0000000000000000000000000000000000000000..14f2dbbba75c0962f18f779e8cfb20e5f98ccfb7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/invalid_access_modifier.ets @@ -0,0 +1,27 @@ +/* + * 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. + */ + +class A{ + private \\\\foo(){} +} + +/* @@? 17:13 Error SyntaxError: Invalid character. */ +/* @@? 17:13 Error SyntaxError: Access modifier must precede field and method modifiers. */ +/* @@? 17:14 Error SyntaxError: Invalid character. */ +/* @@? 17:14 Error SyntaxError: Access modifier must precede field and method modifiers. */ +/* @@? 17:15 Error SyntaxError: Invalid character. */ +/* @@? 17:15 Error SyntaxError: Access modifier must precede field and method modifiers. */ +/* @@? 17:16 Error SyntaxError: Invalid character. */ +/* @@? 17:16 Error SyntaxError: Access modifier must precede field and method modifiers. */