diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 95113ed59c675d244b23db736b586f42413d9e07..a0dd5dc276455014b888a31e1e434d66f8bfa3c5 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -261,6 +261,10 @@ checker::Type *ETSAnalyzer::Check(ir::MethodDefinition *node) const checker->AddStatus(CheckerStatus::IN_STATIC_BLOCK); } + if (node->TsType() != nullptr && node->TsType()->IsTypeError()) { + return node->TsType(); + } + this->CheckMethodModifiers(node); HandleNativeAndAsyncMethods(checker, node); DoBodyTypeChecking(checker, node, scriptFunc); diff --git a/ets2panda/test/ast/parser/ets/async_this.ets b/ets2panda/test/ast/parser/ets/async_this.ets new file mode 100644 index 0000000000000000000000000000000000000000..7abb732b25bc33d6eea6962267f13c9980ca25e7 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/async_this.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024-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 A{ + async foo(this:A){ + return new Promise((resolve)=>{}) + } +} + +/* @@? 17:15 Error SyntaxError: Unexpected 'this' keyword in non-receiver context. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/extension_function_tests/extension_function_error1.ets b/ets2panda/test/ast/parser/ets/extension_function_tests/extension_function_error1.ets index 47d3887c4c2635fdf1c73651156c33eea74ed591..dc07a979392b8b518cbf1c0fd1e5d8fe3f4e777b 100644 --- a/ets2panda/test/ast/parser/ets/extension_function_tests/extension_function_error1.ets +++ b/ets2panda/test/ast/parser/ets/extension_function_tests/extension_function_error1.ets @@ -17,9 +17,7 @@ function animatableWidth(this: TextAttribute, this { this.width(width); return this; } -/* @@? 16:2 Error TypeError: Cannot find type 'AnimatableExtend'. */ -/* @@? 17:32 Error TypeError: Cannot find type 'TextAttribute'. */ -/* @@? 17:52 Error SyntaxError: The function parameter 'this' must explicitly specify the typeAnnotation. */ -/* @@? 17:52 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 17:54 Error TypeError: Cannot reference 'this' in this context. */ -/* @@? 17:59 Error TypeError: Property 'width' does not exist on type 'Error' */ +/* @@? 16:2 Error TypeError: Cannot find type 'AnimatableExtend'. */ +/* @@? 17:32 Error TypeError: Cannot find type 'TextAttribute'. */ +/* @@? 17:52 Error SyntaxError: The function parameter 'this' must explicitly specify the typeAnnotation. */ +/* @@? 17:52 Error SyntaxError: Unexpected token, expected ',' or ')'. */ diff --git a/ets2panda/test/ast/parser/ets/trailing_lambda_tests/invalid_rest_param_for_await_fuzz.ets b/ets2panda/test/ast/parser/ets/trailing_lambda_tests/invalid_rest_param_for_await_fuzz.ets index d07405831eab31ceda339fc9291d0fb004b43bc7..62c20b2df9dd77f9927cda9f4f64cdf8ca2b24a1 100644 --- a/ets2panda/test/ast/parser/ets/trailing_lambda_tests/invalid_rest_param_for_await_fuzz.ets +++ b/ets2panda/test/ast/parser/ets/trailing_lambda_tests/invalid_rest_param_for_await_fuzz.ets @@ -20,63 +20,62 @@ async WeakMap => ...delete const { Intl } = [ { opt } = [({} ? 4 : Array[-=])]; } -/* @@? 16:7 Error SyntaxError: 'async' flags must be used for functions only at top-level. */ -/* @@? 16:15 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 16:15 Error SyntaxError: Unexpected token, expected '('. */ -/* @@? 16:28 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 16:28 Error SyntaxError: Rest parameter must be the last formal parameter. */ -/* @@? 16:36 Error SyntaxError: Namespace cannot be used as object. */ -/* @@? 16:43 Error SyntaxError: Unexpected token '='. */ -/* @@? 16:43 Error TypeError: Indexed access is not supported for such expression type. */ -/* @@? 16:74 Error SyntaxError: Unexpected token '-='. */ -/* @@? 16:79 Error SyntaxError: Unexpected token, expected ']'. */ -/* @@? 17:1 Error SyntaxError: Unexpected token ','. */ -/* @@? 17:3 Error SyntaxError: Unexpected token '...'. */ -/* @@? 17:15 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ -/* @@? 17:16 Error SyntaxError: Unexpected token '.'. */ -/* @@? 17:17 Error SyntaxError: Unexpected token ':'. */ -/* @@? 17:19 Error SyntaxError: Unexpected token '0'. */ -/* @@? 17:21 Error SyntaxError: Unexpected token, expected ')'. */ -/* @@? 17:22 Error SyntaxError: Unexpected token ']'. */ -/* @@? 17:23 Error SyntaxError: Unexpected token ')'. */ -/* @@? 17:23 Error TypeError: This expression is not callable. */ -/* @@? 17:23 Error TypeError: Indexed access is not supported for such expression type. */ -/* @@? 17:25 Error SyntaxError: Unexpected token ','. */ -/* @@? 17:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 17:27 Error SyntaxError: Unexpected token ':'. */ -/* @@? 17:29 Error SyntaxError: Unexpected token '88'. */ -/* @@? 17:38 Error SyntaxError: Unexpected token ')'. */ -/* @@? 17:39 Error SyntaxError: Unexpected token ','. */ -/* @@? 17:41 Error SyntaxError: Unexpected token '...'. */ -/* @@? 17:44 Error SyntaxError: Unexpected token 'opt'. */ -/* @@? 17:44 Error TypeError: Unresolved reference opt */ -/* @@? 17:47 Error SyntaxError: Unexpected token ','. */ -/* @@? 17:47 Error TypeError: This expression is not callable. */ -/* @@? 17:55 Error SyntaxError: Unexpected token ':'. */ -/* @@? 17:57 Error SyntaxError: Unexpected token. */ -/* @@? 17:62 Error SyntaxError: Unexpected token ']'. */ -/* @@? 17:62 Error TypeError: Indexed access is not supported for such expression type. */ -/* @@? 17:71 Error SyntaxError: Unexpected token '?'. */ -/* @@? 17:73 Error SyntaxError: Unexpected token, expected ')'. */ -/* @@? 17:75 Error SyntaxError: Unexpected token, expected ']'. */ -/* @@? 17:77 Error SyntaxError: Unexpected token, expected ']'. */ -/* @@? 17:78 Error SyntaxError: Unexpected token '}'. */ -/* @@? 17:87 Error SyntaxError: Unexpected token ')'. */ -/* @@? 17:88 Error SyntaxError: Unexpected token ']'. */ -/* @@? 17:89 Error SyntaxError: Unexpected token ']'. */ -/* @@? 18:2 Error SyntaxError: Unexpected token '>>>='. */ -/* @@? 18:7 Error SyntaxError: Unexpected token 'sub'. */ -/* @@? 18:7 Error TypeError: Unresolved reference sub */ -/* @@? 18:24 Error SyntaxError: Unexpected token 'await'. */ -/* @@? 18:24 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 18:24 Error TypeError: Invalid left-hand side of assignment expression */ -/* @@? 18:30 Error SyntaxError: Class cannot be used as object. */ -/* @@? 18:30 Error TypeError: 'await' expressions require Promise object as argument. */ -/* @@? 18:42 Error SyntaxError: Invalid left-hand side in assignment expression. */ -/* @@? 18:58 Error SyntaxError: Unexpected token ')'. */ -/* @@? 18:60 Error TypeError: Unresolved reference missing */ -/* @@? 18:68 Error SyntaxError: Unexpected token ''. */ -/* @@? 18:68 Error SyntaxError: Newline is not allowed in strings */ -/* @@? 18:69 Error SyntaxError: Unexpected token '}'. */ -/* @@? 18:69 Error SyntaxError: Unexpected token '> __a:be'. */ -/* @@? 18:69 Error SyntaxError: Newline is not allowed in strings */ +/* @@? 16:7 Error SyntaxError: 'async' flags must be used for functions only at top-level. */ +/* @@? 16:15 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 16:15 Error SyntaxError: Unexpected token, expected '('. */ +/* @@? 16:28 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 16:28 Error SyntaxError: Rest parameter must be the last formal parameter. */ +/* @@? 16:43 Error SyntaxError: Unexpected token '='. */ +/* @@? 16:43 Error TypeError: Indexed access is not supported for such expression type. */ +/* @@? 16:74 Error SyntaxError: Unexpected token '-='. */ +/* @@? 16:79 Error SyntaxError: Unexpected token, expected ']'. */ +/* @@? 17:1 Error SyntaxError: Unexpected token ','. */ +/* @@? 17:3 Error SyntaxError: Unexpected token '...'. */ +/* @@? 17:15 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */ +/* @@? 17:16 Error SyntaxError: Unexpected token '.'. */ +/* @@? 17:17 Error SyntaxError: Unexpected token ':'. */ +/* @@? 17:19 Error SyntaxError: Unexpected token '0'. */ +/* @@? 17:21 Error SyntaxError: Unexpected token, expected ')'. */ +/* @@? 17:22 Error SyntaxError: Unexpected token ']'. */ +/* @@? 17:23 Error SyntaxError: Unexpected token ')'. */ +/* @@? 17:23 Error TypeError: This expression is not callable. */ +/* @@? 17:23 Error TypeError: Indexed access is not supported for such expression type. */ +/* @@? 17:25 Error SyntaxError: Unexpected token ','. */ +/* @@? 17:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 17:27 Error SyntaxError: Unexpected token ':'. */ +/* @@? 17:29 Error SyntaxError: Unexpected token '88'. */ +/* @@? 17:38 Error SyntaxError: Unexpected token ')'. */ +/* @@? 17:39 Error SyntaxError: Unexpected token ','. */ +/* @@? 17:41 Error SyntaxError: Unexpected token '...'. */ +/* @@? 17:44 Error SyntaxError: Unexpected token 'opt'. */ +/* @@? 17:44 Error TypeError: Unresolved reference opt */ +/* @@? 17:47 Error SyntaxError: Unexpected token ','. */ +/* @@? 17:47 Error TypeError: This expression is not callable. */ +/* @@? 17:55 Error SyntaxError: Unexpected token ':'. */ +/* @@? 17:57 Error SyntaxError: Unexpected token. */ +/* @@? 17:62 Error SyntaxError: Unexpected token ']'. */ +/* @@? 17:62 Error TypeError: Indexed access is not supported for such expression type. */ +/* @@? 17:71 Error SyntaxError: Unexpected token '?'. */ +/* @@? 17:73 Error SyntaxError: Unexpected token, expected ')'. */ +/* @@? 17:75 Error SyntaxError: Unexpected token, expected ']'. */ +/* @@? 17:77 Error SyntaxError: Unexpected token, expected ']'. */ +/* @@? 17:78 Error SyntaxError: Unexpected token '}'. */ +/* @@? 17:87 Error SyntaxError: Unexpected token ')'. */ +/* @@? 17:88 Error SyntaxError: Unexpected token ']'. */ +/* @@? 17:89 Error SyntaxError: Unexpected token ']'. */ +/* @@? 18:2 Error SyntaxError: Unexpected token '>>>='. */ +/* @@? 18:7 Error SyntaxError: Unexpected token 'sub'. */ +/* @@? 18:7 Error TypeError: Unresolved reference sub */ +/* @@? 18:24 Error SyntaxError: Unexpected token 'await'. */ +/* @@? 18:24 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 18:24 Error TypeError: Invalid left-hand side of assignment expression */ +/* @@? 18:30 Error SyntaxError: Class cannot be used as object. */ +/* @@? 18:30 Error TypeError: 'await' expressions require Promise object as argument. */ +/* @@? 18:42 Error SyntaxError: Invalid left-hand side in assignment expression. */ +/* @@? 18:58 Error SyntaxError: Unexpected token ')'. */ +/* @@? 18:60 Error TypeError: Unresolved reference missing */ +/* @@? 18:68 Error SyntaxError: Unexpected token ''. */ +/* @@? 18:68 Error SyntaxError: Newline is not allowed in strings */ +/* @@? 18:69 Error SyntaxError: Unexpected token '}'. */ +/* @@? 18:69 Error SyntaxError: Unexpected token '> __a:be'. */ +/* @@? 18:69 Error SyntaxError: Newline is not allowed in strings */