differentmatt / filbert

JavaScript parser of Python
Other
133 stars 27 forks source link

Closures incorrectly return iterators(?) #65

Closed dzhang314 closed 8 years ago

dzhang314 commented 9 years ago
def makeAdder(n):
    def adder(m):
        return m + n
    return adder

plusThree = makeAdder(3)
self.say(plusThree)                 # plusThree is some kind of function...
self.say(plusThree(2))              # but this produces [object Object], not 5
self.say(plusThree(2).next().value) # oddly enough, this produces 5

I have no idea what's going on under the hood, but it looks like plusThree(2) returns some kind of iterator.

nwinter commented 8 years ago

Fixed with @basicer's new Esper interpreter.