From 578d250389f913c7407b58071fe4cd7e586c446b Mon Sep 17 00:00:00 2001 From: Zhelyapov Aleksey Date: Thu, 30 Nov 2023 21:00:38 +0300 Subject: [PATCH] Fix issue #14105 (additive operations on chars) Signed-off-by: Zhelyapov Aleksey --- ets2panda/checker/ets/helpers.cpp | 4 ++++ ets2panda/compiler/core/ETSGen.h | 1 + 2 files changed, 5 insertions(+) diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index 5e11b6fe85..53f6bead29 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -683,6 +683,10 @@ std::tuple ETSChecker::ApplyBinaryOperatorPromotion(Type *left, Ty return {GlobalLongType(), both_const}; } + if (unboxed_l->IsCharType() && unboxed_r->IsCharType()) { + return {GlobalCharType(), both_const}; + } + return {GlobalIntType(), both_const}; } diff --git a/ets2panda/compiler/core/ETSGen.h b/ets2panda/compiler/core/ETSGen.h index 95aaa9528a..3fd4295604 100644 --- a/ets2panda/compiler/core/ETSGen.h +++ b/ets2panda/compiler/core/ETSGen.h @@ -836,6 +836,7 @@ private: case checker::TypeFlag::ETS_BOOLEAN: case checker::TypeFlag::BYTE: case checker::TypeFlag::SHORT: + case checker::TypeFlag::CHAR: case checker::TypeFlag::INT: { Ra().Emit(node, lhs, if_false); break; -- Gitee