From 0b6f180b576eb32b695f453f7b76abc60b639bb9 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 27 Aug 2020 21:29:48 -0500 Subject: [PATCH] small bugfixes --- src/onyxparser.c | 3 ++- src/onyxsymres.c | 2 +- src/onyxwasm.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/onyxparser.c b/src/onyxparser.c index 520bd6e8..e3163ced 100644 --- a/src/onyxparser.c +++ b/src/onyxparser.c @@ -275,12 +275,13 @@ static AstTyped* parse_factor(OnyxParser* parser) { } case '-': { - consume_token(parser); + OnyxToken* negate_token = expect_token(parser, '-'); AstTyped* factor = parse_factor(parser); AstUnaryOp* negate_node = make_node(AstUnaryOp, Ast_Kind_Unary_Op); negate_node->operation = Unary_Op_Negate; negate_node->expr = factor; + negate_node->token = negate_token; retval = (AstTyped *) negate_node; break; diff --git a/src/onyxsymres.c b/src/onyxsymres.c index 9a36b114..35f0819e 100644 --- a/src/onyxsymres.c +++ b/src/onyxsymres.c @@ -223,7 +223,7 @@ static void symres_unaryop(AstUnaryOp** unaryop) { static void symres_struct_literal(AstStructLiteral* sl) { if (sl->stnode != NULL) symres_expression(&sl->stnode); - if (sl->stnode == NULL) return; + if (sl->stnode == NULL || sl->stnode->kind == Ast_Kind_Error) return; sl->type_node = (AstType *) sl->stnode; sl->type = type_build_from_ast(semstate.allocator, sl->type_node); diff --git a/src/onyxwasm.c b/src/onyxwasm.c index 77e94198..a3740b11 100644 --- a/src/onyxwasm.c +++ b/src/onyxwasm.c @@ -1258,7 +1258,7 @@ COMPILE_FUNC(struct_load, Type* type, u64 offset) { assert(type->kind == Type_Kind_Struct); if (type->Struct.mem_count == 1) { - compile_load_instruction(mod, &code, type->Struct.memarr[0]->type, 0); + compile_load_instruction(mod, &code, type->Struct.memarr[0]->type, offset); *pcode = code; return; } -- 2.25.1