From 3cb9717c62180927628608c521a1a65acfbf12bb Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Sun, 17 Jul 2016 18:08:44 -0700 Subject: [PATCH] Fix #1890 (crash on [1, *[2]]). --- mypy/checkexpr.py | 2 ++ test-data/unit/check-lists.test | 4 ++++ test-data/unit/semanal-errors.test | 2 ++ 3 files changed, 8 insertions(+) diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index 599d67af4899..01dcaa141abd 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -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)): diff --git a/test-data/unit/check-lists.test b/test-data/unit/check-lists.test index 3bafa99245d1..b233991f0ed5 100644 --- a/test-data/unit/check-lists.test +++ b/test-data/unit/check-lists.test @@ -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] diff --git a/test-data/unit/semanal-errors.test b/test-data/unit/semanal-errors.test index 5b506aa84dc4..40d644f5d8de 100644 --- a/test-data/unit/semanal-errors.test +++ b/test-data/unit/semanal-errors.test @@ -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