diff --git a/ets2panda/parser/TypedParser.cpp b/ets2panda/parser/TypedParser.cpp index cdd34f4385219a9c619d81345fdaa78902192ca9..ea49b435789187349f48b5649c62c3bfef1a72c2 100644 --- a/ets2panda/parser/TypedParser.cpp +++ b/ets2panda/parser/TypedParser.cpp @@ -563,6 +563,9 @@ ArenaVector TypedParser::ParseTypeLiteralOrInterface() if (Lexer()->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COMMA && Lexer()->GetToken().Type() != lexer::TokenType::PUNCTUATOR_SEMI_COLON) { + if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SUBSTITUTION) { + ThrowSyntaxError("Interface member initialization is prohibited"); + } if (!Lexer()->GetToken().NewLine()) { ThrowSyntaxError("',' expected"); } diff --git a/ets2panda/test/parser/ets/interface_member_initialization-expected.txt b/ets2panda/test/parser/ets/interface_member_initialization-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..bbc8b1c2e4f0be9a78cf1b52cecf89298c7f963a --- /dev/null +++ b/ets2panda/test/parser/ets/interface_member_initialization-expected.txt @@ -0,0 +1 @@ +SyntaxError: Interface member initialization is prohibited [interface_member_initialization.ets:17:14] diff --git a/ets2panda/test/parser/ets/interface_member_initialization.ets b/ets2panda/test/parser/ets/interface_member_initialization.ets new file mode 100644 index 0000000000000000000000000000000000000000..3aae74b02f8e0f192b7e2c4a1c3dcc02ebee578f --- /dev/null +++ b/ets2panda/test/parser/ets/interface_member_initialization.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2024 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. + */ + +interface Colors { + Red: int = 1; +} + +function main() +{ + +}