py: Fix compiler to handle lambdas used as default arguments.

Addresses issue #1709.
This commit is contained in:
Damien George
2015-12-12 13:42:51 +00:00
parent bb7f5b5501
commit 29e9db0c58
3 changed files with 28 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
# testing default args to a function
def fun1(val=5):
print(val)
@@ -18,3 +20,10 @@ try:
fun2(1, 2, 3, 4)
except TypeError:
print("TypeError")
# lambda as default arg (exposes nested behaviour in compiler)
def f(x=lambda:1):
return x()
print(f())
print(f(f))
print(f(lambda:2))