Skip to content

Commit a64f2e4

Browse files
fix: check arg count for range
1 parent 5f4ef4d commit a64f2e4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mypyc/irbuild/for_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ def get_expr_length(expr: Expression) -> int | None:
12251225
arg_lengths = [get_expr_length(arg) for arg in expr.args]
12261226
if all(arg is not None for arg in arg_lengths):
12271227
return min(arg_lengths) # type: ignore [type-var]
1228-
elif fullname == "builtins.range" and all(isinstance(arg, IntExpr) for arg in expr.args):
1228+
elif fullname == "builtins.range" and len(expr.args) <= 3 and all(isinstance(arg, IntExpr) for arg in expr.args):
12291229
return len(range(*(arg.value for arg in expr.args))) # type: ignore [attr-defined]
12301230

12311231
# TODO: extend this, passing length of listcomp and genexp should have worthwhile

0 commit comments

Comments
 (0)