diff --git a/ets2panda/parser/TypedParser.cpp b/ets2panda/parser/TypedParser.cpp index d7a1834407264781a3745bca70895a5f129c55bb..442431993608e1d5cec8f7e7d5a789a7f3c09e54 100644 --- a/ets2panda/parser/TypedParser.cpp +++ b/ets2panda/parser/TypedParser.cpp @@ -608,14 +608,6 @@ ArenaVector TypedParser::ParseTypeLiteralOrInterfaceBody() if (!Lexer()->GetToken().NewLine()) { LogExpectedToken(lexer::TokenType::PUNCTUATOR_COMMA); } - - if (Lexer()->GetToken().IsKeyword() && (Lexer()->GetToken().Type() != lexer::TokenType::KEYW_STATIC && - Lexer()->GetToken().Type() != lexer::TokenType::KEYW_PRIVATE && - Lexer()->GetToken().Type() != lexer::TokenType::KEYW_DEFAULT)) { - Lexer()->GetToken().SetTokenType(lexer::TokenType::LITERAL_IDENT); - Lexer()->GetToken().SetTokenStr(ERROR_LITERAL); - } - continue; } diff --git a/ets2panda/test/ast/compiler/ets/interface_field.ets b/ets2panda/test/ast/compiler/ets/interface_field.ets index c2e921398045ccf8f25afd621c157e46e4faa57b..c13f647f1097924fe676b33c4585b2adee3391fc 100644 --- a/ets2panda/test/ast/compiler/ets/interface_field.ets +++ b/ets2panda/test/ast/compiler/ets/interface_field.ets @@ -28,18 +28,6 @@ interface Todo { /* @@? 17:19 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 18:22 Error SyntaxError: Label must be followed by a loop statement. */ /* @@? 18:22 Error TypeError: Type name 'string' used in the wrong context */ -/* @@? 21:14 Error SyntaxError: Unexpected token, expected ','. */ -/* @@? 21:14 Error SyntaxError: Identifier expected, got 'identification literal'. */ -/* @@? 21:25 Error TypeError: Cannot find type 'todo'. */ -/* @@? 21:29 Error SyntaxError: Unexpected token, expected ','. */ -/* @@? 21:29 Error SyntaxError: Identifier expected, got 'end of stream'. */ -/* @@? 21:34 Error SyntaxError: Interface fields must have type annotation. */ -/* @@? 21:36 Error TypeError: Cannot find type 'fieldToUpdate'. */ -/* @@? 21:49 Error SyntaxError: Identifier expected, got 'end of stream'. */ -/* @@? 21:49 Error SyntaxError: Unexpected token, expected ','. */ -/* @@? 21:64 Error SyntaxError: Unexpected token, expected '('. */ -/* @@? 21:66 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 21:66 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 21:66 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 21:5 Error SyntaxError: Identifier expected, got 'function'. */ /* @@? 22:16 Error TypeError: need to specify target type for class composite */ -/* @@? 46:1 Error SyntaxError: Unexpected token, expected '}'. */ +/* @@? 34:1 Error SyntaxError: Unexpected token, expected '}'. */ diff --git a/ets2panda/test/ast/compiler/ets/interface_key_word.ets b/ets2panda/test/ast/compiler/ets/interface_key_word.ets new file mode 100644 index 0000000000000000000000000000000000000000..2dc31693a74bd177d0c8e7069d981d78a58de86b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/interface_key_word.ets @@ -0,0 +1,58 @@ +/* + * 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 CCC {} + +interface I { + foo() : boolean; + new() : CCC; + enum() : int; + await() : boolean; + async() : number; +} + +/* @@? 20:5 Error SyntaxError: Constructor signatures are not supported in interfaces, use methods instead! */ +/* @@? 20:5 Error SyntaxError: Identifier expected, got 'new'. */ +/* @@? 20:9 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 20:11 Error SyntaxError: Invalid Type. */ +/* @@? 20:11 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 20:11 Error SyntaxError: Identifier expected, got 'end of stream'. */ +/* @@? 20:16 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 21:5 Error SyntaxError: Invalid Type. */ +/* @@? 21:5 Error SyntaxError: Identifier expected, got 'enum'. */ +/* @@? 21:10 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 21:12 Error SyntaxError: Invalid Type. */ +/* @@? 21:12 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 21:12 Error SyntaxError: Identifier expected, got 'end of stream'. */ +/* @@? 21:14 Error SyntaxError: Identifier expected. */ +/* @@? 21:14 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 21:14 Error SyntaxError: Identifier expected, got 'int'. */ +/* @@? 21:17 Error SyntaxError: Identifier expected. */ +/* @@? 22:5 Error SyntaxError: Identifier expected, got 'await'. */ +/* @@? 22:11 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 22:13 Error SyntaxError: Invalid Type. */ +/* @@? 22:13 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 22:13 Error SyntaxError: Identifier expected, got 'end of stream'. */ +/* @@? 22:15 Error SyntaxError: Identifier expected. */ +/* @@? 22:15 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 22:15 Error SyntaxError: Identifier expected, got 'boolean'. */ +/* @@? 22:22 Error SyntaxError: Identifier expected. */ +/* @@? 23:5 Error SyntaxError: Identifier expected, got 'async'. */ +/* @@? 23:11 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 23:13 Error SyntaxError: Invalid Type. */ +/* @@? 23:13 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 23:13 Error SyntaxError: Identifier expected, got 'end of stream'. */ +/* @@? 23:21 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 24:1 Error SyntaxError: Invalid Type. */ diff --git a/ets2panda/test/ast/compiler/ets/resolve_class_declaration.ets b/ets2panda/test/ast/compiler/ets/resolve_class_declaration.ets index 71569d910a52c5ae72adc8dd214ec4f75eb755e4..3148fbe90d8dcfad1291bca6de38cb65f9b2395f 100644 --- a/ets2panda/test/ast/compiler/ets/resolve_class_declaration.ets +++ b/ets2panda/test/ast/compiler/ets/resolve_class_declaration.ets @@ -26,3 +26,5 @@ interface I { /* @@? 17:31 Error SyntaxError: Identifier expected, got 'end of stream'. */ /* @@? 17:41 Error SyntaxError: Interface fields must have type annotation. */ /* @@? 18:5 Error SyntaxError: Invalid Type. */ +/* @@? 18:5 Error SyntaxError: Identifier expected, got 'return'. */ +/* @@? 18:11 Error SyntaxError: Identifier expected. */