bugfixes related to unary field access and global types
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 8 Jun 2021 22:16:04 +0000 (17:16 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 8 Jun 2021 22:16:04 +0000 (17:16 -0500)
bin/onyx
core/container/map.onyx
src/onyxchecker.c

index 76241afab918a9a7f027aaf386afbd1f0334a71a..ad7d83e7bc510ea0648aacb0dfd8ab76040efc02 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index 60adda30649a003de5d0761d35f467d62b38b816..28be2766954c7c4ee6dd8db8ef53f712c88bb9a1 100644 (file)
@@ -24,7 +24,7 @@ make :: ($Key: type_expr, $Value: type_expr, default := __zero_value(Value), has
     return map;
 }
 
-init :: (use map: ^Map($K, $V), default: V = ~~0, hash_count: i32 = 16) {
+init :: (use map: ^Map($K, $V), default := __zero_value(V), hash_count: i32 = 16) {
     array.init(^hashes, hash_count);
     array.init(^entries, 4);
 
index c6afa1cde51a23d9047cf647e8df1543efe40bfc..17136544052181d9ce567ea7033ee7e62cee06d5 100644 (file)
@@ -881,6 +881,16 @@ CheckStatus check_binaryop(AstBinaryOp** pbinop, b32 assignment_is_ok) {
     if (binop->operation == Binary_Op_Bool_And || binop->operation == Binary_Op_Bool_Or)
         return check_binaryop_bool(pbinop);
 
+    // :UnaryFieldAccessIsGross
+    if (binop->left->kind == Ast_Kind_Unary_Field_Access || binop->right->kind == Ast_Kind_Unary_Field_Access) {
+        if      (type_check_or_auto_cast(&binop->left, binop->right->type));
+        else if (type_check_or_auto_cast(&binop->right, binop->left->type));
+        else {
+            report_bad_binaryop(binop);
+            return Check_Error;
+        }
+    }
+
     // NOTE: The left side cannot be compound.
     //       The right side always is numeric.
     //       The left side cannot be rawptr.
@@ -1401,6 +1411,9 @@ CheckStatus check_field_access(AstFieldAccess** pfield) {
 
 CheckStatus check_method_call(AstBinaryOp** mcall) {
     CHECK(expression, &(*mcall)->left);
+    if ((*mcall)->left->type == NULL) {
+        return Check_Yield_Macro;
+    }
 
     AstTyped* implicit_argument = (*mcall)->left;