From c8cdb22f0b55855b259c3cceb6b2b3734a195271 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 21 Mar 2024 14:42:48 +0000 Subject: Disallow `for x in y.(T)` and `for x in y.?` --- src/check_stmt.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/check_stmt.cpp') 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); -- cgit v1.2.3