small bugfixes
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 28 Aug 2020 02:29:48 +0000 (21:29 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 28 Aug 2020 02:29:48 +0000 (21:29 -0500)
src/onyxparser.c
src/onyxsymres.c
src/onyxwasm.c

index 520bd6e83b6fbbe07504be90e91821e8e1e64ea0..e3163cedb9025dabe50111ad5ee29d9510bf06b8 100644 (file)
@@ -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;
index 9a36b114c73eac3af463b9eacd4c4d4d2a00466e..35f0819e9fe9b12937b1e57c0da294ea08a693ac 100644 (file)
@@ -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);
index 77e941980c45a1dad89f416ae367515b484c1e6a..a3740b11fdcc48c3dd48ec7ca94cb73dd580a233 100644 (file)
@@ -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;
     }