Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Nested list comprehension printed invalid #18

Closed
azz opened this issue Jan 3, 2018 · 1 comment
Closed

Nested list comprehension printed invalid #18

azz opened this issue Jan 3, 2018 · 1 comment
Labels

Comments

@azz
Copy link
Member

azz commented Jan 3, 2018

Input

l = [i for j in k if j%2 == 0 if j*2 < 20 for i in j if i%2==0]

Output

l = [i for j in k if j % 2 == 0 j * 2 < 20 for i in j if i % 2 == 0]

Expected

l = [i for j in k if j % 2 == 0 if j * 2 < 20 for i in j if i % 2 == 0]
#                               ^^

I'm not sure if that's even valid code, but it caused AST_COMPARE to fail on python_expressions/expressions.py.

@azz azz added the bug label Jan 3, 2018
@j-f1
Copy link
Member

j-f1 commented Jan 3, 2018

I'm not sure if that's even valid code

It’s equivalent to:

l = []

for j in k:
    if j % 2 == 0 and j * 2 < 20:
        for i in j:
            if i % 2 == 0:
                l.apppend(i)

ryanashcraft added a commit to ryanashcraft/plugin-python that referenced this issue Mar 5, 2018
ryanashcraft added a commit to ryanashcraft/plugin-python that referenced this issue Mar 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants