diff options
Diffstat (limited to 'types.c')
-rw-r--r-- | types.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -63,7 +63,7 @@ static bool type_eq(Type *a, Type *b) { if (b->flags & TYPE_FLAG_FLEXIBLE) return true; assert(a->kind == TYPE_BUILTIN); - if (a->builtin == BUILTIN_FLOAT) { + if (type_builtin_is_floating(a->builtin)) { return type_builtin_is_floating(b->builtin); } assert(a->builtin == BUILTIN_I64); @@ -254,7 +254,7 @@ static bool type_of_expr(Expression *e, Type *t) { break; case EXPR_FLOAT_LITERAL: t->kind = TYPE_BUILTIN; - t->builtin = BUILTIN_FLOAT; + t->builtin = BUILTIN_F32; t->flags |= TYPE_FLAG_FLEXIBLE; break; case EXPR_IDENT: { @@ -331,9 +331,9 @@ static bool type_of_expr(Expression *e, Type *t) { int rhs_is_flexible = rhs_type->flags & TYPE_FLAG_FLEXIBLE; if (lhs_is_flexible && rhs_is_flexible) { *t = *lhs_type; - if (rhs_type->builtin == BUILTIN_FLOAT) { + if (rhs_type->builtin == BUILTIN_F32) { /* promote to float */ - t->builtin = BUILTIN_FLOAT; + t->builtin = BUILTIN_F32; } } else if (type_eq(lhs_type, rhs_type)) { if (!lhs_is_flexible) @@ -400,7 +400,9 @@ static bool types_block(Block *b) { arr_foreach(&b->stmts, Statement, s) { if (!types_stmt(s)) ret = false; } - if (b->ret_expr) types_expr(b->ret_expr); + if (b->ret_expr) + if (!types_expr(b->ret_expr)) + ret = false; block_exit(b, &b->stmts); return ret; } |