From 395d49ca5e9c0673bb298a88da87e84f05ddcd07 Mon Sep 17 00:00:00 2001 From: wangzhengji Date: Mon, 1 Sep 2025 20:52:36 +0800 Subject: [PATCH] Fix missing CTE type widen Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICVAZ0 Signed-off-by: wangzhengji --- ets2panda/checker/ETSAnalyzer.cpp | 2 +- .../ets/update_expression_type_widen.ets | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 ets2panda/test/ast/compiler/ets/update_expression_type_widen.ets diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index ab87ed9b46..6617b37046 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -2995,7 +2995,7 @@ checker::Type *ETSAnalyzer::Check(ir::UpdateExpression *expr) const return expr->SetTsType(checker->GlobalTypeError()); } - return expr->SetTsType(operandType); + return expr->SetTsType(checker->ApplyUnaryOperatorPromotion(expr->argument_, operandType)); } // compile methods for LITERAL EXPRESSIONS in alphabetical order diff --git a/ets2panda/test/ast/compiler/ets/update_expression_type_widen.ets b/ets2panda/test/ast/compiler/ets/update_expression_type_widen.ets new file mode 100644 index 0000000000..43a461178b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/update_expression_type_widen.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. + */ + +function want_byte(x: byte) { +} +let b: byte = 1 +want_byte(++b) + +/* @@? 19:1 Error TypeError: No matching call signature for want_byte(Int) */ +/* @@? 19:11 Error TypeError: Type 'Int' is not compatible with type 'Byte' at index 1 */ -- Gitee