Lichen

Annotated tests/nested_lambda.py

601:adcdaeb19307
2017-02-19 Paul Boddie Fixed the context test and set operation to replace the local context with any applicable attribute context. Added a test of method rebinding that requires this fix. method-wrapper-for-context
paul@2 1
a = 4
paul@2 2
paul@2 3
def f(x):
paul@266 4
    #   f.$l0          f.$l0.$l0
paul@43 5
    g = lambda y, x=x: lambda z, x=x, y=y: (x, y, z, a)
paul@2 6
    return g
paul@2 7
paul@266 8
print f                 # __main__.f
paul@266 9
print f(1)              # __main__.f.$l0
paul@266 10
print f(1)(2)           # __main__.f.$l0.$l0
paul@266 11
paul@2 12
result = f(1)(2)(3)
paul@214 13
print result[0]
paul@214 14
print result[1]
paul@214 15
print result[2]
paul@214 16
print result[3]
paul@266 17
print result            # (1, 2, 3, 4)