diff --git a/ets2panda/checker/ets/typeCheckingHelpers.cpp b/ets2panda/checker/ets/typeCheckingHelpers.cpp index a077b6024fdc9b925cf610346a53633ee73ebfdb..4820200af0814d5ccb1ff03ed2efdc4f200864ca 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -435,6 +435,11 @@ Type *ETSChecker::GetTypeOfSetterGetter(varbinder::Variable *const var) return propType->FindGetter()->ReturnType(); } + if (propType->FindSetter()->Params().empty()) { + var->SetTsType(GlobalTypeError()); + return GlobalTypeError(); + } + return propType->FindSetter()->Params()[0]->TsType(); } diff --git a/ets2panda/test/ast/compiler/ets/set_init_without_param.ets b/ets2panda/test/ast/compiler/ets/set_init_without_param.ets new file mode 100644 index 0000000000000000000000000000000000000000..266f904738f58e3d180c7f8b0f73b1dfde6cb7c2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/set_init_without_param.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +set a '1;' + +/* @@? 16:1 Error SyntaxError: Extension Setter can only have 2 parameters. */ +/* @@? 16:5 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 16:7 Error SyntaxError: Unexpected token, expected '('. */ +/* @@? 23:1 Error SyntaxError: Expected ')', got 'eos'. */ +/* @@? 23:1 Error SyntaxError: Extension Accessor must have a receiver. */