diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index 54593ef76151ab951bad523c247873c9e7011036..b1fceac3f8c202e53e6e6a0ff3814ff2a305abaa 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -364,6 +364,7 @@ bool ETSChecker::CheckDefaultTypeParameter(const ir::TSTypeParameter *param, Typ typeParameterDecls.count(variable) == 0U) { LogError(diagnostic::TYPE_PARAM_USE_BEFORE_DEFINE, {defaultTypePart->Name()->AsIdentifier()->Name().Utf8()}, node->Start()); + variable->SetTsType(GlobalTypeError()); ok = false; } else if (defaultType != nullptr && defaultType->IsTypeError()) { ok = false; diff --git a/ets2panda/test/ast/compiler/ets/type_parameter.ets b/ets2panda/test/ast/compiler/ets/type_parameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..d453160a29bae5fff51f25ffed42675bab83ce7a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/type_parameter.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. + */ + +type foo + +let a : foo = 1; + +/* @@? 16:15 Error TypeError: Type Parameter T should be defined before use. */ +/* @@? 18:1 Error SyntaxError: Expected '=', got 'let'. */ +/* @@? 18:1 Error SyntaxError: Invalid Type. */