diff options
| -rw-r--r-- | examples/learnxiny.tm | 2 | ||||
| -rw-r--r-- | src/typecheck.c | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/examples/learnxiny.tm b/examples/learnxiny.tm index b585a2ab..7373f057 100644 --- a/examples/learnxiny.tm +++ b/examples/learnxiny.tm @@ -111,7 +111,7 @@ func main(): # The value returned is optional because none will be returned if the key # is not in the table: >> table["xxx"] - = none : Int + = none # Optional values can be converted to regular values using `!` (which will # create a runtime error if the value is null): 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)); |
