Opened 6 years ago

Closed 6 years ago

#598 closed defect (fixed)

generator expressions do not work in closures

Reported by: scoder Owned by: scoder
Priority: major Milestone: 0.14
Component: Code Generation Keywords:


# cython: language_level=3

def list_comp_in_closure():
    >>> list_comp_in_closure()
    [0, 4, 8]
    x = 'abc'
    def f():
        return x
    result = [x*2 for x in range(5) if x % 2 == 0]
    assert x == 'abc' # don't leak in Py3 code
    assert f() == 'abc' # don't leak in Py3 code
    return result

generates invalid C code: the loop variable is defined in the closure struct but has a different name inside of the function code.

Change History (3)

comment:2 Changed 6 years ago by scoder

  • Milestone changed from wishlist to 0.13.1
  • Owner changed from somebody to scoder
  • Status changed from new to assigned

comment:3 Changed 6 years ago by scoder

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.