From 46834d443479a59ce27574c87dce326aa8b9b99c Mon Sep 17 00:00:00 2001 From: xuxinjie4 Date: Sat, 12 Jul 2025 16:30:17 +0800 Subject: [PATCH] Fix unexpected token in param list Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICLRWI?from=project-issue Signed-off-by: xuxinjie4 --- ets2panda/parser/ETSparser.cpp | 5 ++- .../compiler/ets/fuzzing_invalid_override.ets | 10 +++--- .../ast/compiler/ets/unexpected_param_01.ets | 36 +++++++++++++++++++ .../ast/compiler/ets/unexpected_param_02.ets | 18 ++++++++++ .../ets/FixedArray/MultipleParserErrors.ets | 32 +++++++++-------- .../ast/parser/ets/MultipleParserErrors.ets | 32 ++++++++++------- .../annotationUsage_bad_param07.ets | 5 ++- ...ionUsage_missing_AT_for_function_param.ets | 9 ++--- .../ast/parser/ets/async_function_bad.ets | 1 - .../ets/empty_array_map_inference_fail.ets | 19 +++++----- 10 files changed, 118 insertions(+), 49 deletions(-) create mode 100644 ets2panda/test/ast/compiler/ets/unexpected_param_01.ets create mode 100644 ets2panda/test/ast/compiler/ets/unexpected_param_02.ets diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 5f4a27cc9c..d41b161955 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -1452,8 +1452,11 @@ ir::Expression *ETSParser::ParseFunctionParameter() typeAnnotation->SetParent(paramIdent); paramIdent->SetTsTypeAnnotation(typeAnnotation); paramIdent->SetEnd(typeAnnotation->End()); - } else if (!isArrow && !isOptional) { + } + + if ((!isArrow || isOptional) && paramIdent->TypeAnnotation() == nullptr) { LogError(diagnostic::EXPLICIT_PARAM_TYPE); + paramIdent->SetTsTypeAnnotation(AllocBrokenType(Lexer()->GetToken().Loc())); } return ParseFunctionParameterExpression(paramIdent, isOptional); diff --git a/ets2panda/test/ast/compiler/ets/fuzzing_invalid_override.ets b/ets2panda/test/ast/compiler/ets/fuzzing_invalid_override.ets index 960aae81e8..dab8545e3c 100644 --- a/ets2panda/test/ast/compiler/ets/fuzzing_invalid_override.ets +++ b/ets2panda/test/ast/compiler/ets/fuzzing_invalid_override.ets @@ -27,6 +27,7 @@ export default class HashMap implements ReadonlyHashMap { /* @@? 20:69 Error TypeError: HashMap is not abstract and does not override abstract method forEach(callbackFn: (value: V, key: K, map: ReadonlyHashMap) => void): void in ReadonlyHashMap */ /* @@? 21:12 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 21:12 Error TypeError: Only abstract or native methods can't have body. */ /* @@? 21:17 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 21:17 Error SyntaxError: The function parameter 'this' must explicitly specify the typeAnnotation. */ /* @@? 21:17 Error SyntaxError: Unexpected token '.'. */ @@ -44,19 +45,20 @@ export default class HashMap implements ReadonlyHashMap { /* @@? 22:21 Error SyntaxError: Field type annotation expected. */ /* @@? 22:21 Error SyntaxError: Unexpected token '.'. */ /* @@? 22:30 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 22:30 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 22:30 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 22:30 Error SyntaxError: Unexpected token '('. */ +/* @@? 22:30 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 22:30 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 22:39 Error SyntaxError: Unexpected token ','. */ /* @@? 22:47 Error SyntaxError: Unexpected token ')'. */ /* @@? 22:49 Error SyntaxError: Unexpected token '=>'. */ /* @@? 22:52 Error SyntaxError: Unexpected token '{'. */ /* @@? 23:23 Error TypeError: Only abstract or native methods can't have body. */ -/* @@? 23:24 Error TypeError: The type of parameter 'value' cannot be inferred */ +/* @@? 23:23 Error TypeError: Only abstract or native methods can't have body. */ /* @@? 23:29 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 23:31 Error TypeError: The type of parameter 'key' cannot be inferred */ /* @@? 23:34 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 23:40 Error SyntaxError: The function parameter 'this' must explicitly specify the typeAnnotation. */ /* @@? 24:10 Error SyntaxError: Unexpected token ')'. */ +/* @@? 24:10 Error SyntaxError: Unexpected token ')'. */ /* @@? 25:5 Error SyntaxError: Unexpected token '}'. */ /* @@? 26:1 Error SyntaxError: Unexpected token '}'. */ + diff --git a/ets2panda/test/ast/compiler/ets/unexpected_param_01.ets b/ets2panda/test/ast/compiler/ets/unexpected_param_01.ets new file mode 100644 index 0000000000..3708ac4deb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/unexpected_param_01.ets @@ -0,0 +1,36 @@ +/* + * 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. + */ + +let byteP: Promise = byteFunc() +let pthen = byteP.then((value ? Object): Object => { + return value + +}); +await byteP; + +/* @@? 16:30 Error TypeError: Unresolved reference byteFunc */ +/* @@? 17:41 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 17:41 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 17:41 Error SyntaxError: Expected '=>', got 'identification literal'. */ +/* @@? 17:41 Error TypeError: Class name 'Object' used in the wrong context */ +/* @@? 17:41 Error TypeError: Class name 'Object' used in the wrong context */ +/* @@? 17:48 Error SyntaxError: Unexpected token ':'. */ +/* @@? 17:48 Error SyntaxError: Unexpected token ':'. */ +/* @@? 17:48 Error SyntaxError: Unexpected token ':'. */ +/* @@? 17:50 Error TypeError: The type of parameter 'Object' cannot be inferred */ +/* @@? 18:12 Error TypeError: Unresolved reference value */ +/* @@? 20:2 Error SyntaxError: Unexpected token ')'. */ +/* @@? 20:2 Error SyntaxError: Unexpected token ')'. */ +/* @@? 20:2 Error SyntaxError: Unexpected token ')'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/unexpected_param_02.ets b/ets2panda/test/ast/compiler/ets/unexpected_param_02.ets new file mode 100644 index 0000000000..c5bb53c7eb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/unexpected_param_02.ets @@ -0,0 +1,18 @@ +/* + * 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. + */ + +function foo(a?){} + +/* @@? 16:16 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/FixedArray/MultipleParserErrors.ets b/ets2panda/test/ast/parser/ets/FixedArray/MultipleParserErrors.ets index 78b272bb38..d4fb78174c 100644 --- a/ets2panda/test/ast/parser/ets/FixedArray/MultipleParserErrors.ets +++ b/ets2panda/test/ast/parser/ets/FixedArray/MultipleParserErrors.ets @@ -170,6 +170,7 @@ function main(): void { /* @@? 28:29 Error TypeError: Native, Abstract and Declare methods cannot have body. */ /* @@? 34:14 Error SyntaxError: The modifier for a constructor should be limited to access modifiers (private, internal, protected, public), and 'native' modifiers. */ /* @@? 37:41 Error SyntaxError: Only 'throws' can be used with function types. */ +/* @@? 39:10 Error TypeError: Only abstract or native methods can't have body. */ /* @@? 39:14 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 39:14 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 39:14 Error SyntaxError: Unexpected token, expected an identifier. */ @@ -181,24 +182,24 @@ function main(): void { /* @@? 39:31 Error SyntaxError: return keyword should be used in function body. */ /* @@? 39:38 Error TypeError: All return statements in the function should be empty or have a value. */ /* @@? 41:6 Error SyntaxError: Identifier expected, got 'number literal'. */ -/* @@? 43:6 Error SyntaxError: Type alias name cannot be 'null'. */ /* @@? 43:6 Error SyntaxError: Identifier expected, got 'null'. */ +/* @@? 43:6 Error SyntaxError: Type alias name cannot be 'null'. */ /* @@? 45:6 Error SyntaxError: Identifier expected, got 'this'. */ /* @@? 47:8 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 47:8 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 47:8 Error TypeError: Missing initializer in const declaration */ -/* @@? 49:12 Error TypeError: The type of parameter 'a' cannot be inferred */ /* @@? 49:13 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 51:10 Error TypeError: Only abstract or native methods can't have body. */ /* @@? 51:35 Error SyntaxError: Rest parameter must be the last formal parameter. */ /* @@? 51:37 Error SyntaxError: Unexpected token '...'. */ /* @@? 51:37 Error SyntaxError: Unexpected token '...'. */ /* @@? 51:43 Error SyntaxError: Label must be followed by a loop statement. */ /* @@? 51:43 Error TypeError: Unresolved reference FixedArray */ /* @@? 51:58 Error SyntaxError: Unexpected token, expected '('. */ -/* @@? 51:59 Error SyntaxError: Unexpected token ':'. */ /* @@? 51:59 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 51:59 Error SyntaxError: Unexpected token ':'. */ -/* @@? 51:59 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 51:59 Error SyntaxError: Unexpected token ':'. */ +/* @@? 51:59 Error SyntaxError: Unexpected token ':'. */ /* @@? 51:59 Error SyntaxError: Unexpected token ':'. */ /* @@? 51:61 Error SyntaxError: Unexpected token 'int'. */ /* @@? 51:61 Error SyntaxError: Unexpected token 'int'. */ @@ -221,16 +222,15 @@ function main(): void { /* @@? 92:7 Error TypeError: Variable 'A' has already been declared. */ /* @@? 93:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ /* @@? 103:25 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 104:1 Error TypeError: Function foo with this assembly signature already declared. */ +/* @@? 104:1 Error TypeError: Function foo with this assembly signature already declared. */ /* @@? 104:32 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 115:10 Error TypeError: Only abstract or native methods can't have body. */ /* @@? 115:26 Error SyntaxError: Unexpected token 'case'. */ /* @@? 115:26 Error SyntaxError: Unexpected token 'case'. */ /* @@? 115:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 115:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 115:26 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 115:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 115:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 115:26 Error SyntaxError: Unexpected token 'case'. */ -/* @@? 115:26 Error SyntaxError: Unexpected token 'case'. */ /* @@? 115:30 Error SyntaxError: Unexpected token ':'. */ /* @@? 115:30 Error SyntaxError: Unexpected token ':'. */ /* @@? 115:32 Error TypeError: Unresolved reference U */ @@ -243,11 +243,14 @@ function main(): void { /* @@? 115:38 Error SyntaxError: Unexpected token '{'. */ /* @@? 116:5 Error SyntaxError: return keyword should be used in function body. */ /* @@? 116:12 Error TypeError: All return statements in the function should be empty or have a value. */ -/* @@? 119:26 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 119:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 119:1 Error TypeError: Function foo with this assembly signature already declared. */ +/* @@? 119:1 Error TypeError: Function foo with this assembly signature already declared. */ +/* @@? 119:10 Error TypeError: Only abstract or native methods can't have body. */ /* @@? 119:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 119:26 Error SyntaxError: Unexpected token 'case'. */ /* @@? 119:26 Error SyntaxError: Unexpected token 'case'. */ +/* @@? 119:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 119:26 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 119:30 Error SyntaxError: Unexpected token ':'. */ /* @@? 119:30 Error SyntaxError: Unexpected token ':'. */ /* @@? 119:33 Error SyntaxError: Unexpected token ')'. */ @@ -273,7 +276,8 @@ function main(): void { /* @@? 137:19 Error SyntaxError: Unexpected token ')'. */ /* @@? 137:19 Error SyntaxError: Unexpected token ')'. */ /* @@? 137:19 Error SyntaxError: Unexpected token ')'. */ -/* @@? 141:16 Error TypeError: This expression is not callable. */ +/* @@? 141:5 Error TypeError: No matching call signature for assertTrue(Promise, undefined) */ +/* @@? 141:16 Error TypeError: Type 'Promise' is not compatible with type 'boolean' at index 1 */ /* @@? 145:18 Error TypeError: A is abstract therefore cannot be instantiated. */ /* @@? 146:16 Error TypeError: Bad operand type, the types of the operands must be numeric, same enumeration, or boolean type. */ /* @@? 148:25 Error TypeError: A is abstract therefore cannot be instantiated. */ @@ -285,8 +289,8 @@ function main(): void { /* @@? 161:9 Error SyntaxError: Identifier expected, got 'let'. */ /* @@? 162:9 Error SyntaxError: Identifier expected, got 'const'. */ /* @@? 163:9 Error SyntaxError: Identifier expected, got 'new'. */ -/* @@? 164:5 Error TypeError: This expression is not callable. */ -/* @@? 165:5 Error TypeError: This expression is not callable. */ +/* @@? 164:5 Error TypeError: Reference to foo is ambiguous */ +/* @@? 165:5 Error TypeError: Reference to foo is ambiguous */ /* @@? 166:5 Error TypeError: Expected 1 arguments, got 0. */ /* @@? 166:5 Error TypeError: No matching call signature */ -/* @@? 293:1 Error SyntaxError: Expected '}', got 'eos'. */ +/* @@? 297:1 Error SyntaxError: Expected '}', got 'eos'. */ diff --git a/ets2panda/test/ast/parser/ets/MultipleParserErrors.ets b/ets2panda/test/ast/parser/ets/MultipleParserErrors.ets index 758b001e43..49953eb181 100644 --- a/ets2panda/test/ast/parser/ets/MultipleParserErrors.ets +++ b/ets2panda/test/ast/parser/ets/MultipleParserErrors.ets @@ -170,6 +170,7 @@ function main(): void { /* @@? 28:29 Error TypeError: Native, Abstract and Declare methods cannot have body. */ /* @@? 34:14 Error SyntaxError: The modifier for a constructor should be limited to access modifiers (private, internal, protected, public), and 'native' modifiers. */ /* @@? 37:41 Error SyntaxError: Only 'throws' can be used with function types. */ +/* @@? 39:10 Error TypeError: Only abstract or native methods can't have body. */ /* @@? 39:14 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 39:14 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 39:14 Error SyntaxError: Unexpected token, expected an identifier. */ @@ -187,8 +188,8 @@ function main(): void { /* @@? 47:8 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 47:8 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 47:8 Error TypeError: Missing initializer in const declaration */ -/* @@? 49:12 Error TypeError: The type of parameter 'a' cannot be inferred */ /* @@? 49:13 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 51:10 Error TypeError: Only abstract or native methods can't have body. */ /* @@? 51:25 Error SyntaxError: Rest parameter must be the last formal parameter. */ /* @@? 51:27 Error SyntaxError: Unexpected token '...'. */ /* @@? 51:27 Error SyntaxError: Unexpected token '...'. */ @@ -201,8 +202,8 @@ function main(): void { /* @@? 51:41 Error SyntaxError: Unexpected token 'int'. */ /* @@? 51:41 Error SyntaxError: Unexpected token 'int'. */ /* @@? 52:5 Error SyntaxError: return keyword should be used in function body. */ -/* @@? 52:12 Error TypeError: Unresolved reference q */ /* @@? 52:12 Error TypeError: All return statements in the function should be empty or have a value. */ +/* @@? 52:12 Error TypeError: Unresolved reference q */ /* @@? 52:23 Error TypeError: Unresolved reference p */ /* @@? 55:26 Error SyntaxError: Rest parameter should be either array or tuple type. */ /* @@? 59:23 Error SyntaxError: Rest parameter should be either array or tuple type. */ @@ -219,12 +220,15 @@ function main(): void { /* @@? 92:7 Error TypeError: Variable 'A' has already been declared. */ /* @@? 93:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ /* @@? 103:25 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 104:1 Error TypeError: Function foo with this assembly signature already declared. */ +/* @@? 104:1 Error TypeError: Function foo with this assembly signature already declared. */ /* @@? 104:32 Error SyntaxError: Rest parameter should be either array or tuple type. */ -/* @@? 115:26 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 115:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 115:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 115:10 Error TypeError: Only abstract or native methods can't have body. */ /* @@? 115:26 Error SyntaxError: Unexpected token 'case'. */ /* @@? 115:26 Error SyntaxError: Unexpected token 'case'. */ +/* @@? 115:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 115:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 115:26 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 115:30 Error SyntaxError: Unexpected token ':'. */ /* @@? 115:30 Error SyntaxError: Unexpected token ':'. */ /* @@? 115:32 Error TypeError: Unresolved reference U */ @@ -237,11 +241,14 @@ function main(): void { /* @@? 115:38 Error SyntaxError: Unexpected token '{'. */ /* @@? 116:5 Error SyntaxError: return keyword should be used in function body. */ /* @@? 116:12 Error TypeError: All return statements in the function should be empty or have a value. */ +/* @@? 119:1 Error TypeError: Function foo with this assembly signature already declared. */ +/* @@? 119:1 Error TypeError: Function foo with this assembly signature already declared. */ +/* @@? 119:10 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 119:26 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 119:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 119:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 119:26 Error SyntaxError: Unexpected token 'case'. */ /* @@? 119:26 Error SyntaxError: Unexpected token 'case'. */ -/* @@? 119:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 119:26 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 119:30 Error SyntaxError: Unexpected token ':'. */ /* @@? 119:30 Error SyntaxError: Unexpected token ':'. */ /* @@? 119:33 Error SyntaxError: Unexpected token ')'. */ @@ -254,8 +261,8 @@ function main(): void { /* @@? 120:12 Error TypeError: All return statements in the function should be empty or have a value. */ /* @@? 123:5 Error SyntaxError: Identifier expected, got ','. */ /* @@? 123:6 Error SyntaxError: Variable must be initialized or it's type must be declared. */ -/* @@? 123:6 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 123:6 Error SyntaxError: Unexpected token 'abc'. */ +/* @@? 123:6 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 123:6 Error TypeError: Unresolved reference abc */ /* @@? 127:1 Error SyntaxError: The modifier async cannot be used in an ambient context. */ /* @@? 132:14 Error SyntaxError: Unexpected token, expected an identifier. */ @@ -267,7 +274,8 @@ function main(): void { /* @@? 137:19 Error SyntaxError: Unexpected token ')'. */ /* @@? 137:19 Error SyntaxError: Unexpected token ')'. */ /* @@? 137:19 Error SyntaxError: Unexpected token ')'. */ -/* @@? 141:16 Error TypeError: This expression is not callable. */ +/* @@? 141:5 Error TypeError: No matching call signature for assertTrue(Promise, undefined) */ +/* @@? 141:16 Error TypeError: Type 'Promise' is not compatible with type 'boolean' at index 1 */ /* @@? 145:18 Error TypeError: A is abstract therefore cannot be instantiated. */ /* @@? 146:16 Error TypeError: Bad operand type, the types of the operands must be numeric, same enumeration, or boolean type. */ /* @@? 148:25 Error TypeError: A is abstract therefore cannot be instantiated. */ @@ -279,8 +287,8 @@ function main(): void { /* @@? 161:9 Error SyntaxError: Identifier expected, got 'let'. */ /* @@? 162:9 Error SyntaxError: Identifier expected, got 'const'. */ /* @@? 163:9 Error SyntaxError: Identifier expected, got 'new'. */ -/* @@? 164:5 Error TypeError: This expression is not callable. */ -/* @@? 165:5 Error TypeError: This expression is not callable. */ +/* @@? 164:5 Error TypeError: Reference to foo is ambiguous */ +/* @@? 165:5 Error TypeError: Reference to foo is ambiguous */ /* @@? 166:5 Error TypeError: Expected 1 arguments, got 0. */ /* @@? 166:5 Error TypeError: No matching call signature */ -/* @@? 287:1 Error SyntaxError: Expected '}', got 'eos'. */ +/* @@? 295:1 Error SyntaxError: Expected '}', got 'eos'. */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param07.ets b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param07.ets index c1e3d6541e..322cbe2b6c 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param07.ets +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param07.ets @@ -19,7 +19,6 @@ } -function foo(@MyAnno ...a/* @@ label */){} - -/* @@@ label Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +function foo(@MyAnno ...a){} /* @@? 22:15 Error TypeError: The required field 'testProperty1' must be specified. Fields without default values cannot be omitted. */ +/* @@? 22:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_missing_AT_for_function_param.ets b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_missing_AT_for_function_param.ets index 6516d74eb9..418f7c974c 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_missing_AT_for_function_param.ets +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_missing_AT_for_function_param.ets @@ -26,20 +26,18 @@ function foo(MyAnno({testProperty1: ""}) x: int, MyAnno({testProperty1: ""}) y: } /* @@? 19:10 Error TypeError: Only abstract or native methods can't have body. */ -/* @@? 19:14 Error TypeError: The type of parameter 'MyAnno' cannot be inferred */ /* @@? 19:20 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 19:20 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 19:20 Error TypeError: need to specify target type for class composite */ /* @@? 19:42 Error SyntaxError: Unexpected token 'x'. */ -/* @@? 19:45 Error SyntaxError: Unexpected token 'int'. */ /* @@? 19:45 Error SyntaxError: Label must be followed by a loop statement. */ /* @@? 19:45 Error SyntaxError: Unexpected token 'int'. */ +/* @@? 19:45 Error SyntaxError: Unexpected token 'int'. */ /* @@? 19:48 Error SyntaxError: Unexpected token ')'. */ /* @@? 19:48 Error SyntaxError: Unexpected token ')'. */ /* @@? 22:1 Error TypeError: Function foo is already declared. */ -/* @@? 22:14 Error TypeError: The type of parameter 'MyAnno' cannot be inferred */ -/* @@? 22:20 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 22:20 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 22:20 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 22:20 Error TypeError: need to specify target type for class composite */ /* @@? 22:42 Error SyntaxError: Unexpected token 'x'. */ /* @@? 22:45 Error SyntaxError: Label must be followed by a loop statement. */ @@ -57,7 +55,6 @@ function foo(MyAnno({testProperty1: ""}) x: int, MyAnno({testProperty1: ""}) y: /* @@? 22:87 Error SyntaxError: Unexpected token ')'. */ /* @@? 25:1 Error TypeError: Function foo is already declared. */ /* @@? 25:1 Error TypeError: Function foo is already declared. */ -/* @@? 25:14 Error TypeError: The type of parameter 'MyAnno' cannot be inferred */ /* @@? 25:20 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 25:20 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 25:20 Error TypeError: need to specify target type for class composite */ @@ -74,4 +71,4 @@ function foo(MyAnno({testProperty1: ""}) x: int, MyAnno({testProperty1: ""}) y: /* @@? 25:81 Error TypeError: Type name 'string' used in the wrong context */ /* @@? 25:87 Error SyntaxError: Unexpected token ')'. */ /* @@? 25:87 Error SyntaxError: Unexpected token ')'. */ -/* @@? 25:87 Error SyntaxError: Unexpected token ')'. */ +/* @@? 25:87 Error SyntaxError: Unexpected token ')'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/async_function_bad.ets b/ets2panda/test/ast/parser/ets/async_function_bad.ets index 6d7733236c..de045b598a 100644 --- a/ets2panda/test/ast/parser/ets/async_function_bad.ets +++ b/ets2panda/test/ast/parser/ets/async_function_bad.ets @@ -19,7 +19,6 @@ async native function foo(): Promise; /* @@? 16:14 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 16:14 Error SyntaxError: Unexpected token, expected '('. */ /* @@? 16:14 Error TypeError: Only abstract or native methods can't have body. */ -/* @@? 16:23 Error TypeError: The type of parameter 'foo' cannot be inferred */ /* @@? 16:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 16:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 16:27 Error SyntaxError: Unexpected token ')'. */ diff --git a/ets2panda/test/ast/parser/ets/empty_array_map_inference_fail.ets b/ets2panda/test/ast/parser/ets/empty_array_map_inference_fail.ets index 9552cc43a9..35054abe63 100644 --- a/ets2panda/test/ast/parser/ets/empty_array_map_inference_fail.ets +++ b/ets2panda/test/ast/parser/ets/empty_array_map_inference_fail.ets @@ -21,18 +21,21 @@ return x+1; }); -/* @@? 16:1 Error TypeError: No matching call signature */ -/* @@? 16:1 Error TypeError: Expected 1 arguments, got 0. */ -/* @@? 16:2 Error SyntaxError: Unexpected token, expected ')'. */ -/* @@? 16:2 Error SyntaxError: Unexpected token 'function'. */ +/* @@? 16:1 Error TypeError: Expected 1 arguments, got 0. */ +/* @@? 16:1 Error TypeError: No matching call signature */ +/* @@? 16:2 Error SyntaxError: Unexpected token 'function'. */ +/* @@? 16:2 Error SyntaxError: Unexpected token, expected ')'. */ /* @@? 18:2 Error SyntaxError: Unexpected token ')'. */ -/* @@? 18:4 Error SyntaxError: Unexpected token ')'. */ -/* @@? 20:1 Error TypeError: Can't resolve array type */ +/* @@? 18:2 Error SyntaxError: Unexpected token ')'. */ +/* @@? 18:2 Error SyntaxError: Unexpected token ')'. */ +/* @@? 18:4 Error SyntaxError: Unexpected token ')'. */ +/* @@? 20:1 Error TypeError: Can't resolve array type */ /* @@? 20:8 Error SyntaxError: Unexpected token 'function'. */ /* @@? 20:8 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 20:8 Error SyntaxError: Unexpected token 'function'. */ /* @@? 20:16 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 20:17 Error TypeError: The type of parameter 'x' cannot be inferred */ /* @@? 20:18 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 22:2 Error SyntaxError: Unexpected token ')'. */ +/* @@? 22:2 Error SyntaxError: Unexpected token ')'. */ +/* @@? 22:2 Error SyntaxError: Unexpected token ')'. */ -- Gitee