Repository: serge-sans-paille/beniget

Issue:
Variable lenght arguments in lambda are ignored
```python
lambda *args: args
```

The code above generates the following warning: 

```
W: unbound identifier 'args' at ./test.py:1:14
```

Discussion:
serge-sans-paille: Clean and simple, thanks!

Patch:
diff --git a/beniget/beniget.py b/beniget/beniget.py
index fe38b13..efe40bb 100644
--- a/beniget/beniget.py
+++ b/beniget/beniget.py
@@ -1058,6 +1058,7 @@ class DefUseChains(ast.NodeVisitor):
             dnode = self.chains.setdefault(node, Def(node))
             for default in node.args.defaults:
                 self.visit(default).add_user(dnode)
+            # a lambda never has kw_defaults
             self._defered.append((node,
                                   list(self._definitions),
                                   list(self._scopes),
@@ -1067,7 +1068,7 @@ class DefUseChains(ast.NodeVisitor):
         elif step is DefinitionStep:
             dnode = self.chains[node]
             with self.ScopeContext(node):
-                for a in node.args.args:
+                for a in _iter_arguments(node.args):
                     self.visit(a)
                 self.visit(node.body).add_user(dnode)
             return dnode


Test patch:
diff --git a/tests/test_chains.py b/tests/test_chains.py
index d2fa72c..ff309e7 100644
--- a/tests/test_chains.py
+++ b/tests/test_chains.py
@@ -357,6 +357,14 @@ while done:
             'x -> (x -> (Tuple -> (Lambda -> ())))',
         ])
 
+    def test_lambda_varargs(self):
+        node, c = self.checkChains( "lambda *args: args", [])
+        self.assertEqual(c.dump_chains(node.body[0].value), ['args -> (args -> (Lambda -> ()))'])
+    
+    def test_lambda_kwargs(self):
+        node, c = self.checkChains( "lambda **kwargs: kwargs", [])
+        self.assertEqual(c.dump_chains(node.body[0].value), ['kwargs -> (kwargs -> (Lambda -> ()))'])
+
     def test_multiple_import_as(self):
         code = "import x as y, z; y"
         self.checkChains(code, ["y -> (y -> ())", "z -> ()"])