summaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-10-06 22:01:59 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2019-10-06 22:01:59 -0400
commit2f8808172f2bb35119fe8f654f5a01a8247b6770 (patch)
tree2c7bd37c0694bb4ca17e80765484df5dd6213f2a /types.c
parent8fb6f22fa34497225b94fb6bdcf2a59dae0da6fa (diff)
a few small bug fixes involving eval
Diffstat (limited to 'types.c')
-rw-r--r--types.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/types.c b/types.c
index e619225..66a6e6f 100644
--- a/types.c
+++ b/types.c
@@ -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;
}
}