summaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
Diffstat (limited to 'types.c')
-rw-r--r--types.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/types.c b/types.c
index e6b7cdc..e619225 100644
--- a/types.c
+++ b/types.c
@@ -1028,9 +1028,9 @@ static bool types_decl(Typer *tr, Declaration *d) {
d->type.flags &= ~TYPE_FLAG_FLEXIBLE; /* x := 5; => x is not flexible */
}
if (d->flags & DECL_FLAG_CONST) {
- if (!d->val) {
- d->val = typer_malloc(tr, sizeof *d->val); /* OPTIM */
- eval_expr(tr->evalr, &d->expr, d->val);
+ if (!(d->flags & DECL_FLAG_FOUND_VAL)) {
+ eval_expr(tr->evalr, &d->expr, &d->val);
+ d->flags |= DECL_FLAG_FOUND_VAL;
}
}
}