bug fixes with operator overloading with anonymous struct literals
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 25 Sep 2021 17:24:47 +0000 (12:24 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 25 Sep 2021 17:24:47 +0000 (12:24 -0500)
bin/onyx
examples/14_overloaded_procs.onyx
src/checker.c
src/utils.c

index 7325797ceb81cdb41a8b37b8a500f94bcc0572ed..6989ac3995e134573bf32fdbe37e670f8668be67 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index d7c6df1a53a0bd10053de7a3f904e1a63d7a5058..3abe4debd8bd5cac8e59161a485ec15b7611674d 100644 (file)
@@ -51,9 +51,9 @@ main :: (args: [] cstr) {
     // a datatype you made, or a map with keys of a datatype you made, you need to provide an overload
     // to core.hash.to_u32 for your datatype. In this program, that definition is at the end of the file.
     person_set := set.make(Person);
-    person_set << Person.{ "Joe", 38 };
-    person_set << Person.{ "Jane", 36 };
-    person_set << Person.{ "Joe", 38 };
+    person_set << .{ "Joe", 38 };
+    person_set << .{ "Jane", 36 };
+    person_set << .{ "Joe", 38 };
 
     // "Joe" will only be printed once.
     for person: set.iterator(^person_set) {
index b948d7fa185b4adcfa5b6299ecf05b3eff8ba239..9d790122184c514ccf1fe39f2d5eca69481d65b0 100644 (file)
@@ -917,8 +917,8 @@ CheckStatus check_binaryop(AstBinaryOp** pbinop) {
     }
 
     // NOTE: Try operator overloading before checking everything else.
-    if ((binop->left->type != NULL && binop->right->type != NULL) &&
-        (binop->left->type->kind != Type_Kind_Basic || binop->right->type->kind != Type_Kind_Basic)) {
+    if ((binop->left->type != NULL && binop->left->type->kind != Type_Kind_Basic)
+        || (binop->right->type != NULL && binop->right->type->kind != Type_Kind_Basic)) {
         AstCall *implicit_call = binaryop_try_operator_overload(binop);
 
         if (implicit_call == (AstCall *) &node_that_signals_a_yield)
index fe4722c69c2c873daff0b521d19baef83af7f1f0..4abd861a05b310ffa0b3837d3cef8d4040f54275 100644 (file)
@@ -565,6 +565,8 @@ AstFunction* macro_resolve_header(AstMacro* macro, Arguments* args, OnyxToken* c
 
         default: assert(("Bad macro body type.", 0));
     }
+
+    return NULL;
 }
 
 b32 entity_bring_to_state(Entity* ent, EntityState state) {