2016-09-08 | Paul Boddie | file changeset files shortlog | Changed nested scope tests to work without implicit name propagation. |
paul@2 | 1 | class C: |
paul@2 | 2 | def c(self): |
paul@2 | 3 | return 1 |
paul@2 | 4 | |
paul@2 | 5 | class D: |
paul@2 | 6 | def d(self): |
paul@2 | 7 | return 3 |
paul@2 | 8 | |
paul@2 | 9 | a = 4 |
paul@2 | 10 | |
paul@2 | 11 | def f(x): |
paul@2 | 12 | x.c() |
paul@43 | 13 | def g(y, x=x): # x must be introduced as default here |
paul@2 | 14 | if y: |
paul@2 | 15 | x = D() |
paul@2 | 16 | return x.d(), y, a # UnboundLocalError in Python (if y is a false value) |
paul@2 | 17 | return g |
paul@2 | 18 | |
paul@2 | 19 | result = f(C())(2) |
paul@2 | 20 | assert result == (3, 2, 4) |