diff --git a/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp b/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp index d9ede70dc70e83d757ebbd3be280e8859230dada..867bf893299f1128110158a1222c76da3ac2f99d 100644 --- a/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp +++ b/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp @@ -27,6 +27,9 @@ static bool HasDefaultParameters(const ir::ScriptFunction *function, util::Diagn bool hasRestParameter = false; for (auto *const it : function->Params()) { + if (it->IsBrokenExpression()) { + continue; + } auto const *const param = it->AsETSParameterExpression(); if (param->IsRestParameter()) { @@ -299,6 +302,9 @@ bool DefaultParametersInConstructorLowering::PostconditionForModule([[maybe_unus return false; } for (auto *const it : node->AsMethodDefinition()->Function()->Params()) { + if (it->IsBrokenExpression()) { + return false; + } auto const *const param = it->AsETSParameterExpression(); if (param->IsOptional()) { return true; diff --git a/ets2panda/test/ast/compiler/ets/constructor_parameter.ets b/ets2panda/test/ast/compiler/ets/constructor_parameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..7952f53fefcf3aef1a82ad633e840380788fae06 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/constructor_parameter.ets @@ -0,0 +1,23 @@ +/* + * 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 A { + constructor (this. +} + +/* @@? 17:17 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 17:22 Error SyntaxError: The function parameter 'this' must explicitly specify the typeAnnotation. */ +/* @@? 17:22 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 17:22 Error SyntaxError: Unexpected token '.'. */