mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
py: Fix compiler to handle lambdas used as default arguments.
Addresses issue #1709.
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user