aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen.c')
-rw-r--r--src/codegen.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/codegen.c b/src/codegen.c
index 6fc7848..665f071 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -240,6 +240,10 @@ codegendecl(struct cgctx ctx, idx_t i)
assert(ctx.ast.kinds[i] == ASTDECL);
+ /* Don’t assign a default value to ‘x: int = …’ */
+ if (ctx.aux.buf[p.lhs].decl.isundef)
+ return fwdnode(ctx.ast, i);
+
if (!ctx.types[i].isfloat && ctx.aux.buf[p.lhs].decl.isstatic) {
strview_t sv = ctx.toks.strs[ctx.ast.lexemes[i]];
/* TODO: Namespace the name */