Skip to content

Fix #1890 (crash on [1, *[2]]). #1893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,8 @@ def check_argument_types(self, arg_types: List[Type], arg_kinds: List[int],
for i, actuals in enumerate(formal_to_actual):
for actual in actuals:
arg_type = arg_types[actual]
if arg_type is None:
continue # Some kind of error was already reported.
# Check that a *arg is valid as varargs.
if (arg_kinds[actual] == nodes.ARG_STAR and
not self.is_valid_var_arg(arg_type)):
Expand Down
4 changes: 4 additions & 0 deletions test-data/unit/check-lists.test
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ class C: pass
[builtins fixtures/list.py]
[out]
main: note: In function "f":

[case testListContainingStarExpr]
a = [1, *[2]] # E: Can use starred expression only as assignment target
[builtins fixtures/list.py]
2 changes: 2 additions & 0 deletions test-data/unit/semanal-errors.test
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,11 @@ c = 1
d = 1
a = *b
a = b, (c, *d)
a = [1, *[2]]
[out]
main:4: error: Can use starred expression only as assignment target
main:5: error: Can use starred expression only as assignment target
main:6: error: Can use starred expression only as assignment target

[case testStarExpressionInExp]
a = 1
Expand Down