py/compile: Do proper checking of * and ** in function definition.

This patch checks that there is only one *, and that ** is last in the
arg list.
This commit is contained in:
Damien George
2015-11-23 16:50:42 +00:00
parent 0e3f29cc99
commit 9a56912ad1
3 changed files with 21 additions and 3 deletions

View File

@@ -113,3 +113,11 @@ test_syntax('def f(x):\n nonlocal x')
# can define variable to be both nonlocal and global
test_syntax('def f():\n nonlocal x\n global x')
# can't have multiple *'s
test_syntax('def f(x, *a, *):\n pass')
test_syntax('lambda x, *a, *: 1')
# **kw must be last
test_syntax('def f(x, *a, **kw, r):\n pass')
test_syntax('lambda x, *a, **kw, r: 1')