From a9e4d231808aba5b146197ab59450c9035354b7f Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Wed, 2 Feb 2022 19:35:04 -0500 Subject: Remove default initialization to 0 for variable declarations This made sense when all variables were of the same size, but now with arrays we don't initialize them by default. Perhaps we should find a way to 0-initialize all the memory? --- src/parser.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/parser.c') diff --git a/src/parser.c b/src/parser.c index 479767d..435191d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -258,6 +258,9 @@ Node *parse_var_declaration(Lexer *lexer) if (token.type == TOKEN_ASSIGN) { if (is_global) die_location(token.loc, "Cannot initialize global variable `%s` outside function", node->var_decl.var.name); + if (node->var_decl.var.type->type == TYPE_ARRAY) + die_location(token.loc, "Cannot initialize array variable `%s` here.", node->var_decl.var.name); + node->var_decl.value = parse_expression(lexer); if (!type_equals(node->var_decl.var.type, node->var_decl.value->expr_type)) { -- cgit v1.2.3