diff options
| author | gingerBill <bill@gingerbill.org> | 2024-03-18 11:21:06 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-03-18 11:21:06 +0000 |
| commit | 43d695a9900ff72064c93ada30a882720af8d489 (patch) | |
| tree | c1bbe125aded20618939ebc532d0b89ce377af94 /src/check_stmt.cpp | |
| parent | 19eb2a8890e41d088d96e4608737bbede5508f59 (diff) | |
Fix `for x in y` where `y` is an "optional ok" value, but ignores `#optional_allocator_error` values
Diffstat (limited to 'src/check_stmt.cpp')
| -rw-r--r-- | src/check_stmt.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index d31af08da..a6ca4b9dd 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -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)); |