Skip to content

Commit 3cb9717

Browse files
author
Guido van Rossum
committed
Fix #1890 (crash on [1, *[2]]).
1 parent b268332 commit 3cb9717

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

mypy/checkexpr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,8 @@ def check_argument_types(self, arg_types: List[Type], arg_kinds: List[int],
661661
for i, actuals in enumerate(formal_to_actual):
662662
for actual in actuals:
663663
arg_type = arg_types[actual]
664+
if arg_type is None:
665+
continue # Some kind of error was already reported.
664666
# Check that a *arg is valid as varargs.
665667
if (arg_kinds[actual] == nodes.ARG_STAR and
666668
not self.is_valid_var_arg(arg_type)):

test-data/unit/check-lists.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,7 @@ class C: pass
6262
[builtins fixtures/list.py]
6363
[out]
6464
main: note: In function "f":
65+
66+
[case testListContainingStarExpr]
67+
a = [1, *[2]] # E: Can use starred expression only as assignment target
68+
[builtins fixtures/list.py]

test-data/unit/semanal-errors.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,11 @@ c = 1
487487
d = 1
488488
a = *b
489489
a = b, (c, *d)
490+
a = [1, *[2]]
490491
[out]
491492
main:4: error: Can use starred expression only as assignment target
492493
main:5: error: Can use starred expression only as assignment target
494+
main:6: error: Can use starred expression only as assignment target
493495

494496
[case testStarExpressionInExp]
495497
a = 1

0 commit comments

Comments
 (0)