diff --git a/ets2panda/parser/ETSparserTypes.cpp b/ets2panda/parser/ETSparserTypes.cpp index 6853f67fada877ee6424d518db9162ab13c5b611..b9de9440bedb563eb0c48964812e7a2893a826c3 100644 --- a/ets2panda/parser/ETSparserTypes.cpp +++ b/ets2panda/parser/ETSparserTypes.cpp @@ -359,6 +359,17 @@ std::pair ETSParser::GetTypeAnnotationFromToken(TypeAnnota return std::make_pair(ParseETSTupleType(options), true); case lexer::TokenType::KEYW_THIS: return std::make_pair(ParseThisType(options), true); + case lexer::TokenType::PUNCTUATOR_LEFT_BRACE: + if (((*options) & TypeAnnotationParsingOptions::REPORT_ERROR) != 0) { + auto startPos = Lexer()->GetToken().Start(); + auto modifiers = ir::ClassDefinitionModifiers::ID_REQUIRED | ir::ClassDefinitionModifiers::CLASS_DECL | + ir::ClassDefinitionModifiers::DECLARATION; + auto flags = ir::ModifierFlags::NONE; + ParseClassBody(modifiers, flags); + LogError(diagnostic::ERROR_ARKTS_NO_OBJ_LITERAL_TO_DECL_TYPE, {}, startPos); + return {AllocBrokenType({startPos, Lexer()->GetToken().End()}), false}; + } + [[fallthrough]]; default: { return {nullptr, true}; } diff --git a/ets2panda/test/ast/compiler/ets/class_cyclic_constructor.ets b/ets2panda/test/ast/compiler/ets/class_cyclic_constructor.ets index 0a68437b939f63d72b1a7b1cccd4af70912e02b5..e20b1aa5d3678238e627562a63e621a326dc85f1 100644 --- a/ets2panda/test/ast/compiler/ets/class_cyclic_constructor.ets +++ b/ets2panda/test/ast/compiler/ets/class_cyclic_constructor.ets @@ -34,16 +34,14 @@ class A { /* @@? 24:9 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 24:9 Error SyntaxError: Unexpected token 'let'. */ /* @@? 24:9 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 24:20 Error SyntaxError: Invalid Type. */ -/* @@? 24:20 Error SyntaxError: Unexpected token '{'. */ +/* @@? 24:20 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 24:21 Error SyntaxError: Unexpected token '{'. */ /* @@? 24:23 Error SyntaxError: Field type annotation expected. */ /* @@? 24:23 Error SyntaxError: Unexpected token '.'. */ /* @@? 24:31 Error SyntaxError: Field type annotation expected. */ -/* @@? 24:32 Error SyntaxError: Unexpected token '}'. */ -/* @@? 24:37 Error SyntaxError: Unexpected token. */ -/* @@? 24:38 Error SyntaxError: Unexpected token. */ -/* @@? 24:51 Error SyntaxError: Unexpected token '}'. */ +/* @@? 24:34 Error SyntaxError: Unexpected token '='. */ +/* @@? 24:36 Error SyntaxError: Unexpected token '{'. */ +/* @@? 24:38 Error TypeError: Unresolved reference caches */ /* @@? 25:21 Error TypeError: Expected 0 arguments, got 1. */ /* @@? 25:21 Error TypeError: No matching construct signature for class_cyclic_constructor.A(...tuple) */ /* @@? 25:27 Error TypeError: Spread argument cannot be passed for ordinary parameter. */ diff --git a/ets2panda/test/ast/compiler/ets/create_partial.ets b/ets2panda/test/ast/compiler/ets/create_partial.ets new file mode 100644 index 0000000000000000000000000000000000000000..ed646d63c558098be89310f4c47661c8572e34a2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/create_partial.ets @@ -0,0 +1,69 @@ +/* + * 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. + */ + +interface Todo { + title: string; + teTodo(todo1, { + descriptio + description: string; + } + tion:"throw out + function updateTodo(todo:Todo, fieldToUpdate: Partial) { + return {...todo, ...fieldToUpdate }; + } + + const todo1: Todo = { + title: "original desk", + de "ription: "clea, + }; + + const todo2 = updateTodo(todo1, { + description:"throw out trash", + }); + +/* @@? 18:15 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 18:17 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 18:17 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 18:17 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 19:5 Error TypeError: Unresolved reference descriptio */ +/* @@? 20:18 Error SyntaxError: Label must be followed by a loop statement. */ +/* @@? 20:18 Error TypeError: Type name 'string' used in the wrong context */ +/* @@? 22:8 Error SyntaxError: Newline is not allowed in strings */ +/* @@? 22:18 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 22:18 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 23:65 Error TypeError: need to specify target type for class composite */ +/* @@? 26:1 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 26:1 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 26:1 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 26:1 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 26:1 Error TypeError: Cannot find type 'todo1'. */ +/* @@? 27:24 Error SyntaxError: Unexpected token ','. */ +/* @@? 28:28 Error SyntaxError: Unexpected token ','. */ +/* @@? 28:28 Error SyntaxError: Field type annotation expected. */ +/* @@? 28:28 Error SyntaxError: Unexpected token 'ription: '. */ +/* @@? 28:28 Error SyntaxError: Field type annotation expected. */ +/* @@? 31:1 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 31:1 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 31:1 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 31:1 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 31:1 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 31:1 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 31:1 Error TypeError: Cannot find type 'updateTodo'. */ +/* @@? 32:36 Error SyntaxError: Unexpected token ','. */ +/* @@? 33:35 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 33:35 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 33:35 Error SyntaxError: Identifier expected. */ +/* @@? 33:35 Error TypeError: Property '*ERROR_LITERAL*' must be accessed through 'this' */ +/* @@? 69:67 Error SyntaxError: Unexpected token, expected '}'. */ diff --git a/ets2panda/test/ast/compiler/ets/keyof_invalid_argument.ets b/ets2panda/test/ast/compiler/ets/keyof_invalid_argument.ets index 6b2f5eab1a6df8c0bc2096187cba2dbd921f75bc..f7e8a09ad3b5c2ea53f4e9273ca9325c62126c17 100644 --- a/ets2panda/test/ast/compiler/ets/keyof_invalid_argument.ets +++ b/ets2panda/test/ast/compiler/ets/keyof_invalid_argument.ets @@ -23,42 +23,36 @@ class ObservableImpl extends Observable { type NestedKey = T[K] extends object ? keyof T[K] : never; -/* @@? 16:24 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 16:24 Error SyntaxError: Invalid Type. */ -/* @@? 16:26 Error SyntaxError: Unexpected token ','. */ -/* @@? 16:28 Error SyntaxError: Unexpected token 'k'. */ -/* @@? 16:31 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 16:31 Error TypeError: Unresolved reference keyof */ -/* @@? 16:42 Error SyntaxError: Invalid Type. */ -/* @@? 16:42 Error SyntaxError: Unexpected token, expected ')'. */ -/* @@? 16:45 Error SyntaxError: Unexpected token ')'. */ -/* @@? 16:47 Error SyntaxError: Unexpected token '{'. */ +/* @@? 16:24 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 16:42 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 16:45 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ /* @@? 18:33 Error TypeError: Cannot find type 'Observable'. */ /* @@? 18:33 Error TypeError: The super type of 'ObservableImpl' class is not extensible. */ -/* @@? 20:9 Error TypeError: Type 'ObservableImpl' is generic but type argument were not provided. */ -/* @@? 20:24 Error SyntaxError: Invalid Type. */ -/* @@? 20:24 Error SyntaxError: Unexpected token, expected '>'. */ -/* @@? 20:27 Error TypeError: Unresolved reference K */ -/* @@? 20:29 Error SyntaxError: Unexpected token, expected ',' or ']'. */ -/* @@? 20:29 Error SyntaxError: Unexpected token 'in'. */ -/* @@? 20:29 Error TypeError: Unresolved reference in */ -/* @@? 20:32 Error SyntaxError: Unexpected token 'keyof'. */ -/* @@? 20:32 Error TypeError: This expression is not callable. */ -/* @@? 20:41 Error SyntaxError: Unexpected token, expected ')'. */ +/* @@? 20:24 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 20:27 Error SyntaxError: Unexpected token 'K'. */ +/* @@? 20:32 Error SyntaxError: Field type annotation expected. */ +/* @@? 20:41 Error SyntaxError: Unexpected token '&'. */ +/* @@? 20:41 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 20:41 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 20:44 Error SyntaxError: Field type annotation expected. */ +/* @@? 20:44 Error SyntaxError: Unexpected token ')'. */ /* @@? 20:45 Error SyntaxError: Unexpected token ']'. */ /* @@? 20:46 Error SyntaxError: Unexpected token ':'. */ -/* @@? 20:46 Error TypeError: Indexed access is not supported for such expression type. */ -/* @@? 20:60 Error SyntaxError: Unexpected token '>'. */ -/* @@? 20:61 Error SyntaxError: Unexpected token '('. */ -/* @@? 20:62 Error SyntaxError: Unexpected token ')'. */ -/* @@? 22:1 Error SyntaxError: Unexpected token '}'. */ +/* @@? 20:48 Error SyntaxError: Unexpected token '('. */ +/* @@? 20:51 Error SyntaxError: Field type annotation expected. */ +/* @@? 20:51 Error SyntaxError: Unexpected token '&'. */ +/* @@? 20:54 Error SyntaxError: Field type annotation expected. */ +/* @@? 20:54 Error SyntaxError: Unexpected token ')'. */ +/* @@? 20:56 Error SyntaxError: Unexpected token 'K'. */ +/* @@? 20:57 Error SyntaxError: Unexpected token ']'. */ /* @@? 24:36 Error TypeError: The `keyof` keyword can only be used for class or interface type. */ -/* @@? 24:42 Error SyntaxError: Unexpected token ']'. */ /* @@? 24:42 Error SyntaxError: Unexpected token, expected ']'. */ +/* @@? 24:42 Error SyntaxError: Unexpected token ']'. */ /* @@? 24:43 Error SyntaxError: Unexpected token ']'. */ /* @@? 24:45 Error SyntaxError: Unexpected token 'extends'. */ /* @@? 24:53 Error SyntaxError: Unexpected token 'object'. */ /* @@? 24:53 Error TypeError: Type name 'object' used in the wrong context */ +/* @@? 24:62 Error TypeError: Unresolved reference keyof */ /* @@? 24:68 Error SyntaxError: Unexpected token. */ /* @@? 24:68 Error TypeError: Unresolved reference T */ /* @@? 24:68 Error TypeError: Indexed access is not supported for such expression type. */ diff --git a/ets2panda/test/ast/parser/ets/FixedArray/functionTypeParam_neg2.ets b/ets2panda/test/ast/parser/ets/FixedArray/functionTypeParam_neg2.ets index 6651396d4b4f70b98d33b6f13bddcc063ecc15c2..49a08ff7e5c657fe249e7bb2090fec0104ec94d9 100644 --- a/ets2panda/test/ast/parser/ets/FixedArray/functionTypeParam_neg2.ets +++ b/ets2panda/test/ast/parser/ets/FixedArray/functionTypeParam_neg2.ets @@ -23,8 +23,8 @@ declare class Environment { static foo7(props1: {key:string, value:int}[], props2: FixedArray): void; } -/* @@? 17:23 Error SyntaxError: Invalid Type. */ -/* @@? 18:25 Error SyntaxError: Invalid Type. */ +/* @@? 17:23 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 18:25 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 19:25 Error SyntaxError: Invalid Type. */ /* @@? 21:20 Error SyntaxError: Invalid Type. */ /* @@? 21:28 Error SyntaxError: Invalid Type. */ @@ -32,4 +32,5 @@ declare class Environment { /* @@? 21:37 Error SyntaxError: Unexpected token, expected '('. */ /* @@? 21:37 Error SyntaxError: Invalid Type. */ /* @@? 22:20 Error SyntaxError: Invalid Type. */ -/* @@? 23:25 Error SyntaxError: Invalid Type. */ \ No newline at end of file +/* @@? 23:25 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 23:36 Error SyntaxError: Unexpected token ','. */ diff --git a/ets2panda/test/ast/parser/ets/MultipleFunctionErrors.ets b/ets2panda/test/ast/parser/ets/MultipleFunctionErrors.ets index 85f7f8a87135c0e294950d3ebbe3a70f80ae0539..e4ac2d35782c9a20b94cc544bb90aeb0ba88c1f0 100644 --- a/ets2panda/test/ast/parser/ets/MultipleFunctionErrors.ets +++ b/ets2panda/test/ast/parser/ets/MultipleFunctionErrors.ets @@ -17,9 +17,12 @@ function /* @@ label */(): void { } function /* @@ label1 */(): /* @@ label2 */{ - return 77; + /* @@ label3 */return /* @@ label4 */77; } /* @@@ label Error SyntaxError: Unexpected token, expected an identifier. */ /* @@@ label1 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@@ label2 Error SyntaxError: Invalid Type. */ +/* @@@ label1 Error TypeError: Only abstract or native methods can't have body. */ +/* @@@ label2 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@@ label3 Error SyntaxError: Unexpected token 'return'. */ +/* @@@ label4 Error SyntaxError: Unexpected token '77'. */ diff --git a/ets2panda/test/ast/parser/ets/circular_type_in_alias.ets b/ets2panda/test/ast/parser/ets/circular_type_in_alias.ets index 920263f091680b1a7e4356a37f2f30b36b682b12..647e122ae984e7386cfb3cbaf8889349fd1dd353 100644 --- a/ets2panda/test/ast/parser/ets/circular_type_in_alias.ets +++ b/ets2panda/test/ast/parser/ets/circular_type_in_alias.ets @@ -18,21 +18,17 @@ type Loop> = { }; /* @@? 16:24 Error TypeError: Circular type alias reference */ -/* @@? 16:38 Error SyntaxError: Invalid Type. */ -/* @@? 17:6 Error TypeError: Unresolved reference P */ -/* @@? 17:8 Error SyntaxError: Unexpected token, expected ',' or ']'. */ -/* @@? 17:8 Error SyntaxError: Unexpected token 'in'. */ -/* @@? 17:8 Error TypeError: Unresolved reference in */ -/* @@? 17:11 Error SyntaxError: Unexpected token 'keyof'. */ -/* @@? 17:11 Error TypeError: Unresolved reference keyof */ -/* @@? 17:17 Error SyntaxError: Unexpected token 'T'. */ -/* @@? 17:17 Error TypeError: Unresolved reference T */ +/* @@? 16:38 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 17:6 Error SyntaxError: Unexpected token 'P'. */ +/* @@? 17:11 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:17 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:18 Error SyntaxError: Field type annotation expected. */ /* @@? 17:18 Error SyntaxError: Unexpected token ']'. */ /* @@? 17:19 Error SyntaxError: Unexpected token ':'. */ -/* @@? 17:21 Error SyntaxError: Unexpected token 'U'. */ -/* @@? 17:21 Error TypeError: Unresolved reference U */ -/* @@? 17:21 Error TypeError: Indexed access is not supported for such expression type. */ +/* @@? 17:22 Error SyntaxError: Field type annotation expected. */ +/* @@? 17:23 Error SyntaxError: Unexpected token 'P'. */ +/* @@? 17:24 Error SyntaxError: Unexpected token ']'. */ /* @@? 17:26 Error SyntaxError: Unexpected token 'extends'. */ /* @@? 17:34 Error SyntaxError: Unexpected token 'boolean'. */ -/* @@? 17:44 Error TypeError: Type name 'number' used in the wrong context */ -/* @@? 17:53 Error TypeError: Type name 'string' used in the wrong context */ +/* @@? 17:42 Error SyntaxError: Unexpected token '?'. */ +/* @@? 17:44 Error SyntaxError: number is a predefined type, cannot be used as an identifier */ diff --git a/ets2panda/test/ast/parser/ets/functionTypeParam_neg2.ets b/ets2panda/test/ast/parser/ets/functionTypeParam_neg2.ets index b397027c6bc09776e6276193f9c9a1419bf51a80..a6b1b3e066c92cbe76534627c963d174f9967d46 100644 --- a/ets2panda/test/ast/parser/ets/functionTypeParam_neg2.ets +++ b/ets2panda/test/ast/parser/ets/functionTypeParam_neg2.ets @@ -23,8 +23,8 @@ declare class Environment { static foo7(props1: {key:string, value:int}[], props2: int[]): void; } -/* @@? 17:23 Error SyntaxError: Invalid Type. */ -/* @@? 18:25 Error SyntaxError: Invalid Type. */ +/* @@? 17:23 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 18:25 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 19:25 Error SyntaxError: Invalid Type. */ /* @@? 21:20 Error SyntaxError: Invalid Type. */ /* @@? 21:28 Error SyntaxError: Invalid Type. */ @@ -32,4 +32,5 @@ declare class Environment { /* @@? 21:37 Error SyntaxError: Unexpected token, expected '('. */ /* @@? 21:37 Error SyntaxError: Invalid Type. */ /* @@? 22:20 Error SyntaxError: Invalid Type. */ -/* @@? 23:25 Error SyntaxError: Invalid Type. */ \ No newline at end of file +/* @@? 23:25 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 23:36 Error SyntaxError: Unexpected token ','. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/invalid_type_assignment.ets b/ets2panda/test/ast/parser/ets/invalid_type_assignment.ets index c7c6bb00c62ad516e7cc808575e44a6bc7c335a8..057532f5add45d374e1790ee62096d440678ce72 100644 --- a/ets2panda/test/ast/parser/ets/invalid_type_assignment.ets +++ b/ets2panda/test/ast/parser/ets/invalid_type_assignment.ets @@ -20,11 +20,7 @@ flags: [dynamic-ast] type Point = { x: number; y: number }; type AxeX = Point['x']; -/* @@? 20:14 Error SyntaxError: Invalid Type. */ -/* @@? 20:19 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 20:19 Error TypeError: Type name 'number' used in the wrong context */ -/* @@? 20:30 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 20:30 Error TypeError: Type name 'number' used in the wrong context */ +/* @@? 20:14 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 21:19 Error SyntaxError: Unexpected token, expected ']'. */ /* @@? 21:19 Error SyntaxError: Unexpected token ']'. */ /* @@? 21:22 Error SyntaxError: Unexpected token ']'. */ diff --git a/ets2panda/test/ast/parser/ets/namespace_bad_token.ets b/ets2panda/test/ast/parser/ets/namespace_bad_token.ets index 2b279dceae922adf414b83d7989d4b169ba60f3e..5576913d3324f063cc44624d95b259aba988a9d9 100644 --- a/ets2panda/test/ast/parser/ets/namespace_bad_token.ets +++ b/ets2panda/test/ast/parser/ets/namespace_bad_token.ets @@ -17,5 +17,5 @@ declare namespace uiObserver { function on(options: { a: number }, callback: ): void; } -/* @@? 17:26 Error SyntaxError: Invalid Type. */ +/* @@? 17:26 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 17:51 Error SyntaxError: Invalid Type. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/recursive_exported_structure.ets b/ets2panda/test/ast/parser/ets/recursive_exported_structure.ets index f9dc3af5f82fcb76a03f650e2f14a8adf0bdd533..ab4e201454b5217b308f309f1771329a7456194b 100644 --- a/ets2panda/test/ast/parser/ets/recursive_exported_structure.ets +++ b/ets2panda/test/ast/parser/ets/recursive_exported_structure.ets @@ -88,7 +88,7 @@ const _exported: ExportedType = _exportedStructure; export default _exported; -/* @@? 26:26 Error SyntaxError: Invalid Type. */ +/* @@? 26:26 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ /* @@? 41:12 Error TypeError: No matching call signature for (...) */ /* @@? 41:23 Error TypeError: need to specify target type for class composite */ /* @@? 54:20 Error TypeError: No matching call signature for (...) */ diff --git a/ets2panda/test/ast/parser/ets/type_references.ets b/ets2panda/test/ast/parser/ets/type_references.ets index ccd5dcbbdb044e75be1df333b5d19eb5596ebc35..4659ad2318d3ba2c6233d479ebf8516b534424c4 100644 --- a/ets2panda/test/ast/parser/ets/type_references.ets +++ b/ets2panda/test/ast/parser/ets/type_references.ets @@ -20,15 +20,4 @@ let y: G<{a:String}, B> // Error /* @@? 18:8 Error TypeError: Cannot find type 'G'. */ /* @@? 19:8 Error TypeError: Cannot find type 'G'. */ -/* @@? 19:10 Error SyntaxError: Invalid Type. */ -/* @@? 19:10 Error SyntaxError: Unexpected token, expected '>'. */ -/* @@? 19:10 Error SyntaxError: Unexpected token '>'. */ -/* @@? 19:11 Error SyntaxError: Unexpected token 'a'. */ -/* @@? 19:13 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 19:13 Error TypeError: Class name 'String' used in the wrong context */ -/* @@? 19:19 Error SyntaxError: Unexpected token '}'. */ -/* @@? 19:20 Error SyntaxError: Unexpected token ','. */ -/* @@? 19:22 Error SyntaxError: Unexpected token 'B'. */ -/* @@? 19:22 Error TypeError: Type name 'B' used in the wrong context */ -/* @@? 19:22 Error TypeError: Bad operand type, the types of the operands must be numeric, same enumeration, or boolean type. */ -/* @@? 35:1 Error SyntaxError: Unexpected token 'end of stream'. */ +/* @@? 19:10 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ diff --git a/ets2panda/test/unit/lsp/refactors_convert_chain_test.cpp b/ets2panda/test/unit/lsp/refactors_convert_chain_test.cpp index 514202b21a304cd30800faf83fe652c8a7d2c898..3a53f51d66ee0afdcfeede65f1427d35de9ec5e3 100644 --- a/ets2panda/test/unit/lsp/refactors_convert_chain_test.cpp +++ b/ets2panda/test/unit/lsp/refactors_convert_chain_test.cpp @@ -57,14 +57,12 @@ TEST_F(LspChainRefTests, ConvertChainRefactor1) TEST_F(LspChainRefTests, ConvertChainRefactor2) { std::vector files = {"ConvertChainRefactor2.ets"}; - std::vector texts = {R"(interface Foo{ -bar?:{ -baz?:string | null; -} + std::vector texts = {R"(interface A { baz?:string | null; } +interface Foo{ +bar?: A } declare let foo: Foo; -let ccc = /*1*/foo.bar ? -foo.bar.baz : "whenFalse";/*2*/ +let ccc = /*1*/foo.bar ? foo.bar.baz : "whenFalse";/*2*/ )"}; auto filePaths = CreateTempFile(files, texts); @@ -87,14 +85,12 @@ foo.bar.baz : "whenFalse";/*2*/ TEST_F(LspChainRefTests, ConvertChainRefactor3) { std::vector files = {"ConvertChainRefactor3.ets"}; - std::vector texts = {R"(interface Foo{ -bar?:{ -baz: string; -} + std::vector texts = {R"(interface A { baz: string } +interface Foo{ +bar?: A } declare let foo: Foo; -let ccc = /*1*/foo.bar? -foo.bar.baz: "whenFalse";/*2*/ +let ccc = /*1*/foo.bar ? foo.bar.baz: "whenFalse";/*2*/ )"}; auto filePaths = CreateTempFile(files, texts); diff --git a/ets2panda/util/diagnostic/syntax.yaml b/ets2panda/util/diagnostic/syntax.yaml index 753cd09ad1b0c6e2d0ce37817ee324a058e07cc1..3fbf28651e1225e56f7e36a8839857c383df580c 100644 --- a/ets2panda/util/diagnostic/syntax.yaml +++ b/ets2panda/util/diagnostic/syntax.yaml @@ -1243,3 +1243,7 @@ syntax: - name: DEFAULT_PARAM_IN_DECLARE id: 307 message: "A parameter initializer is only allowed in a function or constructor implementation." + +- name: ERROR_ARKTS_NO_OBJ_LITERAL_TO_DECL_TYPE + id: 308 + message: "Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly!"