aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/generator.c5
-rw-r--r--src/parser.c3
2 files changed, 3 insertions, 5 deletions
diff --git a/src/generator.c b/src/generator.c
index f9aa787..4814f4f 100644
--- a/src/generator.c
+++ b/src/generator.c
@@ -280,11 +280,6 @@ void generate_statement(Node *stmt, FILE *out)
generate_expr_into_rax(stmt->var_decl.value, out);
i64 offset = stmt->var_decl.var.offset;
fprintf(out, " mov [rbp-%lld], rax\n", offset);
- } else {
- // Initialize to 0
- i64 offset = stmt->var_decl.var.offset;
- // TODO: Use correct size for the type
- fprintf(out, " mov qword [rbp-%lld], 0\n", offset);
}
} else if (stmt->type == AST_IF) {
assert(stmt->conditional.cond);
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)) {