making, finding and fixing bugs
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 23 Feb 2021 16:23:44 +0000 (10:23 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 23 Feb 2021 16:23:44 +0000 (10:23 -0600)
bin/onyx
src/onyxastnodes.c
src/onyxchecker.c
src/onyxwasm.c

index 0f8bc0e93a3cf54603eb754ca0f62b982e10671a..91908319f54970383784e0500d29173658be425b 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index c3aed5de3d6feedb4f3916baeba3b202241b27c5..0bc14181594a7aa1c69a9555bb8333f2c3dba944 100644 (file)
@@ -188,6 +188,7 @@ AstNumLit* ast_reduce_binop(bh_allocator a, AstBinaryOp* node) {
 
     AstNumLit* res = onyx_ast_node_new(a, sizeof(AstNumLit), Ast_Kind_NumLit);
     res->token = node->token;
+    res->flags |= node->flags;
     res->flags |= Ast_Flag_Comptime;
     res->type_node = node->type_node;
     res->type = node->type;
index 34f674e7dd767b58a866d5c7dfb77722dc96d224..244c202bc86bf2d89cd6b108b2513a135e1e3565 100644 (file)
@@ -1096,7 +1096,7 @@ CheckStatus check_struct_literal(AstStructLiteral* sl) {
             return Check_Error;
         }
 
-        sl->flags &= ((*actual)->flags & Ast_Flag_Comptime);
+        sl->flags &= ((*actual)->flags & Ast_Flag_Comptime) | (sl->flags &~ Ast_Flag_Comptime);
         actual++;
     }
 
@@ -1136,7 +1136,7 @@ CheckStatus check_array_literal(AstArrayLiteral* al) {
     bh_arr_each(AstTyped *, expr, al->values) {
         CHECK(expression, expr);
 
-        al->flags &= ((*expr)->flags & Ast_Flag_Comptime);
+        al->flags &= ((*expr)->flags & Ast_Flag_Comptime) | (al->flags &~ Ast_Flag_Comptime);
 
         if (!type_check_or_auto_cast(expr, elem_type)) {
             onyx_report_error((*expr)->token->pos, "Mismatched types for value of in array, expected '%s', got '%s'.",
@@ -1579,17 +1579,20 @@ CheckStatus check_block(AstBlock* block) {
 
     bh_arr_each(AstTyped *, value, block->allocate_exprs) {
         fill_in_type(*value);
-        if ((*value)->type == NULL) {
-            onyx_report_error((*value)->token->pos,
-                    "Unable to resolve type for local '%b'.",
-                    (*value)->token->text, (*value)->token->length);
-            return Check_Error;
-        }
 
-        if ((*value)->type->kind == Type_Kind_Compound) {
-            onyx_report_error((*value)->token->pos,
-                    "Compound type not allowed as local variable type. Try splitting this into multiple variables.");
-            return Check_Error;
+        if ((*value)->kind == Ast_Kind_Local) {
+            if ((*value)->type == NULL) {
+                onyx_report_error((*value)->token->pos,
+                        "Unable to resolve type for local '%b'.",
+                        (*value)->token->text, (*value)->token->length);
+                return Check_Error;
+            }
+
+            if ((*value)->type->kind == Type_Kind_Compound) {
+                onyx_report_error((*value)->token->pos,
+                        "Compound type not allowed as local variable type. Try splitting this into multiple variables.");
+                return Check_Error;
+            }
         }
     }
 
index 726e4aeab1d11bcd00b6c02cbd2c0ae9c9a50f5c..505d00bfce2ef293d8d151a7635d174ebe1683e8 100644 (file)
@@ -2264,7 +2264,7 @@ EMIT_FUNC(expression, AstTyped* expr) {
             assert(0);
     }
 
-    if (expr->flags & Ast_Flag_Expr_Ignored && !type_results_in_void(expr->type)) {
+    if ((expr->flags & Ast_Flag_Expr_Ignored) != 0 && !type_results_in_void(expr->type)) {
         i32 mem_count = 1;
         if (type_is_compound(expr->type)) mem_count = type_linear_member_count(expr->type);
         fori (i, 0, mem_count) WI(WI_DROP);