Disallow for x in y.(T) and for x in y.?

This commit is contained in:
gingerBill
2024-03-21 14:42:48 +00:00
parent 6e2efce670
commit c8cdb22f0b
+3
View File
@@ -1546,12 +1546,15 @@ gb_internal void check_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags)
} }
} else if (operand.mode != Addressing_Invalid) { } else if (operand.mode != Addressing_Invalid) {
if (operand.mode == Addressing_OptionalOk || operand.mode == Addressing_OptionalOkPtr) { if (operand.mode == Addressing_OptionalOk || operand.mode == Addressing_OptionalOkPtr) {
Ast *expr = unparen_expr(operand.expr);
if (expr->kind != Ast_TypeAssertion) { // Only for procedure calls
Type *end_type = nullptr; Type *end_type = nullptr;
check_promote_optional_ok(ctx, &operand, nullptr, &end_type, false); check_promote_optional_ok(ctx, &operand, nullptr, &end_type, false);
if (is_type_boolean(end_type)) { if (is_type_boolean(end_type)) {
check_promote_optional_ok(ctx, &operand, nullptr, &end_type, true); check_promote_optional_ok(ctx, &operand, nullptr, &end_type, true);
} }
} }
}
bool is_ptr = is_type_pointer(operand.type); bool is_ptr = is_type_pointer(operand.type);
Type *t = base_type(type_deref(operand.type)); Type *t = base_type(type_deref(operand.type));