aboutsummaryrefslogtreecommitdiff
path: root/src/compile/comparisons.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/compile/comparisons.c')
-rw-r--r--src/compile/comparisons.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/compile/comparisons.c b/src/compile/comparisons.c
index bc927599..5e95459c 100644
--- a/src/compile/comparisons.c
+++ b/src/compile/comparisons.c
@@ -28,7 +28,9 @@ Text_t compile_comparison(env_t *env, ast_t *ast) {
type_t *lhs_t = get_type(env, binop.lhs);
type_t *rhs_t = get_type(with_enum_scope(env, lhs_t), binop.rhs);
type_t *operand_t;
- if (binop.lhs->tag == Int && is_numeric_type(rhs_t)) {
+ if (type_eq(lhs_t, rhs_t)) {
+ operand_t = lhs_t;
+ } else if (binop.lhs->tag == Int && is_numeric_type(rhs_t)) {
operand_t = rhs_t;
} else if (binop.rhs->tag == Int && is_numeric_type(lhs_t)) {
operand_t = lhs_t;
@@ -68,7 +70,9 @@ Text_t compile_comparison(env_t *env, ast_t *ast) {
type_t *lhs_t = get_type(env, cmp.lhs);
type_t *rhs_t = get_type(env, cmp.rhs);
type_t *operand_t;
- if (cmp.lhs->tag == Int && is_numeric_type(rhs_t)) {
+ if (type_eq(lhs_t, rhs_t)) {
+ operand_t = lhs_t;
+ } else if (cmp.lhs->tag == Int && is_numeric_type(rhs_t)) {
operand_t = rhs_t;
} else if (cmp.rhs->tag == Int && is_numeric_type(lhs_t)) {
operand_t = lhs_t;