diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2019-10-06 22:01:59 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2019-10-06 22:01:59 -0400 |
commit | 2f8808172f2bb35119fe8f654f5a01a8247b6770 (patch) | |
tree | 2c7bd37c0694bb4ca17e80765484df5dd6213f2a /types.c | |
parent | 8fb6f22fa34497225b94fb6bdcf2a59dae0da6fa (diff) |
a few small bug fixes involving eval
Diffstat (limited to 'types.c')
-rw-r--r-- | types.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -290,8 +290,8 @@ static bool type_resolve(Typer *tr, Type *t) { Expression *n_expr = t->arr.n_expr; if (!types_expr(tr, n_expr)) return false; if (n_expr->type.kind == TYPE_UNKNOWN) { - t->arr.n = 0; - break; + err_print(n_expr->where, "Cannot determine type of array size at compile time."); + return false; } if (n_expr->type.kind != TYPE_BUILTIN || !type_builtin_is_int(n_expr->type.builtin)) { char *s = type_to_str(&n_expr->type); @@ -299,7 +299,8 @@ static bool type_resolve(Typer *tr, Type *t) { free(s); return false; } - eval_expr(tr->evalr, n_expr, &val); + if (!eval_expr(tr->evalr, n_expr, &val)) + return false; U64 size; if (type_builtin_is_signed(n_expr->type.builtin)) { @@ -1029,7 +1030,8 @@ static bool types_decl(Typer *tr, Declaration *d) { } if (d->flags & DECL_FLAG_CONST) { if (!(d->flags & DECL_FLAG_FOUND_VAL)) { - eval_expr(tr->evalr, &d->expr, &d->val); + if (!eval_expr(tr->evalr, &d->expr, &d->val)) + return false; d->flags |= DECL_FLAG_FOUND_VAL; } } |