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

View File

@@ -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);