From: Brendan Hansen Date: Tue, 8 Jun 2021 22:16:04 +0000 (-0500) Subject: bugfixes related to unary field access and global types X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=d5afd7059980049b4c61f8f3685dddc62921d494;p=onyx.git bugfixes related to unary field access and global types --- diff --git a/bin/onyx b/bin/onyx index 76241afa..ad7d83e7 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/core/container/map.onyx b/core/container/map.onyx index 60adda30..28be2766 100644 --- a/core/container/map.onyx +++ b/core/container/map.onyx @@ -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); diff --git a/src/onyxchecker.c b/src/onyxchecker.c index c6afa1cd..17136544 100644 --- a/src/onyxchecker.c +++ b/src/onyxchecker.c @@ -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;