diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-08-16 22:19:28 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-08-16 22:54:53 +0200 |
| commit | f7d7d65bc0f7da6993e117e67e771c7e1741ea06 (patch) | |
| tree | 4a7a3c8a911913488f8225abb4339c8b3b05a061 /src/check_decl.cpp | |
| parent | 970dc7a1f26cbb2badb13ce22bcc51c6055788ef (diff) | |
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.
Diffstat (limited to 'src/check_decl.cpp')
| -rw-r--r-- | src/check_decl.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
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); } |