diff --git a/ets2panda/checker/ets/typeCheckingHelpers.cpp b/ets2panda/checker/ets/typeCheckingHelpers.cpp index 6496cdb8ce75eb3a25d6fc59349a8ce4840f40fc..80d51c1e97ac4efc9b8b3cdad8ccb68a0b9fa26b 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -157,6 +157,10 @@ Type *ETSChecker::RemoveUndefinedType(Type *const type) return type; } + if (type->IsETSPartialTypeParameter()) { + return type; + } + if (type->IsETSUndefinedType()) { return GetGlobalTypesHolder()->GlobalETSNeverType(); } diff --git a/ets2panda/test/ast/compiler/ets/partialType_check_in_RemoveUndefinedType.ets b/ets2panda/test/ast/compiler/ets/partialType_check_in_RemoveUndefinedType.ets new file mode 100644 index 0000000000000000000000000000000000000000..2b6557074b07ccbedd8b296b0c99f794a80e98c9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/partialType_check_in_RemoveUndefinedType.ets @@ -0,0 +1,26 @@ +/* + * 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. + */ + +function genericFunc(p: Partial): void { + if (p !== undefined) { + } +} +function main() { + genericFunc<{a: number, b: string}>({a: 1}) +} + +/* @@? 21:3 Error TypeError: Bad operand type, the types of the operands must be numeric, same enumeration, or boolean type. */ +/* @@? 21:15 Error TypeError: need to specify target type for class composite */ +/* @@? 21:38 Error TypeError: need to specify target type for class composite */