diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-05 02:29:11 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-05 02:29:11 -0400 |
| commit | c9198cb4807931096f6fcc310e567c27923ecccf (patch) | |
| tree | a30d1f35a7893be3289ae21e54dcdf17f3f412db /src | |
| parent | 4299f6e24305d61e6c63b6312af1db887bfa864c (diff) | |
More fixes
Diffstat (limited to 'src')
| -rw-r--r-- | src/typecheck.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/typecheck.c b/src/typecheck.c index bc9ae071..aee96234 100644 --- a/src/typecheck.c +++ b/src/typecheck.c @@ -1172,7 +1172,10 @@ type_t *get_type(env_t *env, ast_t *ast) type_t *lhs_t = get_type(env, binop.lhs); type_t *rhs_t = get_type(env, binop.rhs); - if (can_promote(rhs_t, lhs_t) || can_promote(lhs_t, rhs_t)) + if ((binop.lhs->tag == Int && is_numeric_type(rhs_t)) + || (binop.rhs->tag == Int && is_numeric_type(lhs_t)) + || can_promote(rhs_t, lhs_t) + || can_promote(lhs_t, rhs_t)) return ast->tag == Compare ? Type(IntType, .bits=TYPE_IBITS32) : Type(BoolType); code_err(ast, "I don't know how to compare ", type_to_str(lhs_t), " and ", type_to_str(rhs_t)); |
