diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index ab87ed9b46aab0375ecb4a7396fca515aedbbab6..6617b370466d0645a91458ef6370d6f235454d13 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 0000000000000000000000000000000000000000..43a461178b943b956fa8c11f6be63275f1a613a3 --- /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 */