diff options
author | Laurent Le Brun <laurentlb@google.com> | 2017-02-20 14:04:57 +0000 |
---|---|---|
committer | Irina Iancu <elenairina@google.com> | 2017-02-20 15:34:45 +0000 |
commit | 54b9d2c3d514c7023948930a86db88178309149a (patch) | |
tree | b0ae8c5bf41b8b04795ec791b840927fb6a02cc1 /src/test/java/com/google | |
parent | e86550a5e82f28360cf49ec42318c52973dac93b (diff) |
Raise error in function calls when star argument is not iterable
This was a bug, f(*4) was silently handled as f().
--
PiperOrigin-RevId: 148017021
MOS_MIGRATED_REVID=148017021
Diffstat (limited to 'src/test/java/com/google')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java b/src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java index 2f29dfd1d4..095964344e 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java @@ -308,6 +308,19 @@ public class FunctionTest extends EvaluationTestCase { } @Test + public void testArgsIsNotIterable() throws Exception { + checkEvalError( + "argument after * must be an iterable, not int", + "def func1(a, b): return a + b", + "func1('a', *42)"); + + checkEvalError( + "argument after * must be an iterable, not string", + "def func2(a, b): return a + b", + "func2('a', *'str')"); + } + + @Test public void testKwargs() throws Exception { eval("def foo(a, b = 'b', *, c, d = 'd'):", " return a + b + c + d", |