diff --git a/es2panda/lexer/token/tokenType.h b/es2panda/lexer/token/tokenType.h index 6fe7fb0f0ef21bdbfce9999104ec0aa67ec70489..45a23d0ed2344b6d356d119d746c9e442c3ce040 100644 --- a/es2panda/lexer/token/tokenType.h +++ b/es2panda/lexer/token/tokenType.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -142,6 +142,7 @@ enum class TokenType { KEYW_RETURN, KEYW_STRING, KEYW_SUPER, + KEYW_STRUCT, KEYW_SWITCH, KEYW_SYMBOL, KEYW_THIS, diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 6a1ca88c8ba51e4efcefd264f849c93a809e9a62..8161f7438f266565b9df8e3bce1341cb57e89f57 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -2024,7 +2024,8 @@ void ETSParser::CheckDeclare() case lexer::TokenType::KEYW_FINAL: case lexer::TokenType::KEYW_INTERFACE: case lexer::TokenType::KEYW_TYPE: - case lexer::TokenType::KEYW_ASYNC: { + case lexer::TokenType::KEYW_ASYNC: + case lexer::TokenType::KEYW_STRUCT: { return; } default: { diff --git a/ets2panda/test/ast/compiler/ets/ambient_struct/declare_struct.d.ets b/ets2panda/test/ast/compiler/ets/ambient_struct/declare_struct.d.ets new file mode 100644 index 0000000000000000000000000000000000000000..820aa91867dd36de5024171926e11f96c67cc5bd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/ambient_struct/declare_struct.d.ets @@ -0,0 +1,21 @@ +/* + * 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. + */ + +export declare struct Point2D { + x: number; + y: number; +} + +/* @@? 16:16 Error TypeError: Structs are only used to define UI components, it should be translated at 'plugin after parser' phase. */