aboutsummaryrefslogtreecommitdiff
path: root/src/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/parser.c b/src/parser.c
index fdf34ce..7d991a2 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -62,7 +62,7 @@ int parser_init(Parser *self, amal_compiler *compiler, ArenaAllocator *allocator
return_if_error(structdecl_init(&self->struct_decl, &compiler->root_scope, allocator));
self->struct_decl.body.parser = self;
lhsexpr_init(&self->file_decl, bool_true, bool_true, bool_true, create_buffer_view_null());
- return_if_error(ast_create(self->allocator, &self->struct_decl, AST_STRUCT_DECL, &self->file_decl.rhs_expr));
+ return_if_error(ast_create(self->allocator, &self->struct_decl, AST_STRUCT_DECL, &nullable_raw(self->file_decl.rhs_expr)));
self->current_scope = &self->struct_decl.body;
self->has_func_parent = bool_false;
am_memset(&self->bytecode, 0, sizeof(self->bytecode));
@@ -667,21 +667,21 @@ Ast* parser_parse_body(Parser *self) {
func_decl = parser_parse_closure(self);
if(func_decl) {
- throw_if_error(ast_create(self->allocator, func_decl, AST_FUNCTION_DECL, &lhs_expr->rhs_expr));
+ throw_if_error(ast_create(self->allocator, func_decl, AST_FUNCTION_DECL, &nullable_raw(lhs_expr->rhs_expr)));
return result;
}
struct_decl = parser_parse_struct_decl(self);
if(struct_decl) {
- throw_if_error(ast_create(self->allocator, struct_decl, AST_STRUCT_DECL, &lhs_expr->rhs_expr));
+ throw_if_error(ast_create(self->allocator, struct_decl, AST_STRUCT_DECL, &nullable_raw(lhs_expr->rhs_expr)));
return result;
}
import = parser_parse_import(self);
if(import) {
parser_queue_file(self, import->path, &import->file_scope);
- throw_if_error(ast_create(self->allocator, import, AST_IMPORT, &lhs_expr->rhs_expr));
- parser_parse_body_semicolon(self, lhs_expr->rhs_expr);
+ throw_if_error(ast_create(self->allocator, import, AST_IMPORT, &nullable_raw(lhs_expr->rhs_expr)));
+ parser_parse_body_semicolon(self, nullable_unwrap(lhs_expr->rhs_expr));
return result;
}
} else {
@@ -696,7 +696,7 @@ Ast* parser_parse_body(Parser *self) {
self->error_context = ERROR_CONTEXT_NONE;
/* Variable declaration with lhs and rhs */
if(lhs_expr) {
- lhs_expr->rhs_expr = rhs_expr;
+ nullable_assign(lhs_expr->rhs_expr, rhs_expr);
} else {
bool match;
throw_if_error(tokenizer_consume_if(&self->tokenizer, TOK_EQUALS, &match));