diff options
| author | gingerBill <bill@gingerbill.org> | 2024-03-21 14:42:48 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-03-21 14:42:48 +0000 |
| commit | c8cdb22f0b55855b259c3cceb6b2b3734a195271 (patch) | |
| tree | 589779e5d9f460b1deef336513d76872cffbfb06 /src/check_stmt.cpp | |
| parent | 6e2efce670fa7dd18fbecb7440c6179ddc283218 (diff) | |
Disallow `for x in y.(T)` and `for x in y.?`
Diffstat (limited to 'src/check_stmt.cpp')
| -rw-r--r-- | src/check_stmt.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 17502a6e2..8a876eb01 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1546,10 +1546,13 @@ 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) { - 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); + Ast *expr = unparen_expr(operand.expr); + if (expr->kind != Ast_TypeAssertion) { // Only for procedure calls + 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); |