From f7d7d65bc0f7da6993e117e67e771c7e1741ea06 Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Fri, 16 Aug 2024 22:19:28 +0200 Subject: fix `open` bindings `open` specifies the `mode` argument as vararg (presumably to make it optional). varargs actually have rules about casting, in this case the rule that any integer arg of size <= 4 has to be casted to `i32` before passing it. Not doing that implicit cast makes the permissions wrong or not apply at all. --- src/check_decl.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/check_decl.cpp') diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 090b7f615..c60084ec3 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -691,6 +691,13 @@ gb_internal bool sig_compare(TypeCheckSig *a, TypeCheckSig *b, Type *x, Type *y) } gb_internal bool signature_parameter_similar_enough(Type *x, Type *y) { + if (is_type_bit_set(x)) { + x = bit_set_to_int(x); + } + if (is_type_bit_set(y)) { + y = bit_set_to_int(y); + } + if (sig_compare(is_type_pointer, x, y)) { return true; } @@ -737,6 +744,14 @@ gb_internal bool signature_parameter_similar_enough(Type *x, Type *y) { return true; } + if (sig_compare(is_type_slice, x, y)) { + Type *s1 = core_type(x); + Type *s2 = core_type(y); + if (signature_parameter_similar_enough(s1->Slice.elem, s2->Slice.elem)) { + return true; + } + } + return are_types_identical(x, y); } -- cgit v1.2.3