Skip to content

Comments

Add Py3k warning for list comprehension target rebinding and regression test#45

Open
Eddy114514 wants to merge 3 commits intosoftdevteam:migrationfrom
Eddy114514:listcomp_new
Open

Add Py3k warning for list comprehension target rebinding and regression test#45
Eddy114514 wants to merge 3 commits intosoftdevteam:migrationfrom
Eddy114514:listcomp_new

Conversation

@Eddy114514
Copy link
Collaborator

List comprehensions that rebind an outer name (e.g. x in [x = ...; [x for x in ...]] can cause 2.x vs 3.x behavior differences. Specifically, in python 2, it will rebind the outer variable, but in 3.x, it will not.

I added a symbol-table check in symtable.c to detect listcomp target rebinding and emit the warning. I add test in test_grammer.py and it passed on my local machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant