diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index bf9e8520b45302ea9d2931c959341ae5c77cbe86..2dfece751fa7f13a8998b3cf90e37af0dd3afce0 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -413,6 +413,10 @@ bool ETSChecker::ValidateSignatureRequiredParams(Signature *substitutedSig, { auto commonArity = std::min(arguments.size(), substitutedSig->ArgCount()); if ((flags & TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA) != 0) { + if (commonArity == 0) { + ES2PANDA_ASSERT(substitutedSig->GetSignatureInfo()->params.empty()); + return true; + } commonArity = commonArity - 1; } for (size_t index = 0; index < commonArity; ++index) { diff --git a/ets2panda/test/ast/compiler/ets/builtin_thisArgs.ets b/ets2panda/test/ast/compiler/ets/builtin_thisArgs.ets new file mode 100755 index 0000000000000000000000000000000000000000..2d5aa7df6ac5e29987ecf7ea2a57628965e6a0c6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/builtin_thisArgs.ets @@ -0,0 +1,37 @@ +/* + * 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 MyClass { + compare((value: number, index:number, arr: Array)) {} +} + +/* @@? 16:1 Error TypeError: Class name 'Class' used in the wrong context */ +/* @@? 16:7 Error SyntaxError: Unexpected token 'MyClass'. */ +/* @@? 16:7 Error TypeError: Unresolved reference MyClass */ +/* @@? 16:15 Error SyntaxError: Unexpected token '{'. */ +/* @@? 17:3 Error TypeError: Unresolved reference compare */ +/* @@? 17:17 Error SyntaxError: Unexpected token, expected ')'. */ +/* @@? 17:19 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 17:19 Error SyntaxError: Unexpected token 'number'. */ +/* @@? 17:19 Error TypeError: Type name 'number' used in the wrong context */ +/* @@? 17:25 Error SyntaxError: Unexpected token ','. */ +/* @@? 17:27 Error SyntaxError: Unexpected token 'index'. */ +/* @@? 17:33 Error SyntaxError: Label must be followed by a loop statement. */ +/* @@? 17:33 Error TypeError: Type name 'number' used in the wrong context */ +/* @@? 17:39 Error SyntaxError: Unexpected token ','. */ +/* @@? 17:41 Error SyntaxError: Unexpected token 'arr'. */ +/* @@? 17:46 Error SyntaxError: Label must be followed by a loop statement. */ +/* @@? 17:46 Error TypeError: No matching call signature with trailing lambda */ +/* @@? 17:59 Error SyntaxError: Unexpected token, expected '('. */ \ No newline at end of file