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.
This commit is contained in:
Laytan Laats
2024-08-16 22:19:28 +02:00
parent 970dc7a1f2
commit f7d7d65bc0
8 changed files with 45 additions and 21 deletions

View File

@@ -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);
}