Fix for x in y where y is an "optional ok" value, but ignores #optional_allocator_error values

This commit is contained in:
gingerBill
2024-03-18 11:21:06 +00:00
parent 19eb2a8890
commit 43d695a990
2 changed files with 19 additions and 9 deletions
+5 -1
View File
@@ -1544,7 +1544,11 @@ gb_internal void check_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags)
}
} else if (operand.mode != Addressing_Invalid) {
if (operand.mode == Addressing_OptionalOk || operand.mode == Addressing_OptionalOkPtr) {
check_promote_optional_ok(ctx, &operand, nullptr, nullptr);
Type *end_type = nullptr;
check_promote_optional_ok(ctx, &operand, nullptr, &end_type, false);
if (is_type_boolean(end_type)) {
check_promote_optional_ok(ctx, &operand, nullptr, &end_type, true);
}
}
bool is_ptr = is_type_pointer(operand.type);
Type *t = base_type(type_deref(operand.type));