Two 3.4 fixes..

* LOAD_DEREF does not signal "nonlocal" variables
* Add rule for "if" with a "continue" and "return"
This commit is contained in:
rocky
2018-03-20 04:42:29 -04:00
parent 2e81ee5d2e
commit f008b8f411
4 changed files with 20 additions and 2 deletions

Binary file not shown.

View File

@@ -0,0 +1,16 @@
# Bug in Python 3.4 somewhere after the first 200 programs
def readline(b):
a = 1
while True:
if b:
if b[0]:
a = 2
b = None
continue
b = None
a = 5
return a
assert readline(None) == 1
assert readline([2]) == 2

View File

@@ -44,6 +44,8 @@ class Python34Parser(Python33Parser):
# Is this 3.4 only?
yield_from ::= expr GET_ITER LOAD_CONST YIELD_FROM
_ifstmts_jump ::= c_stmts_opt JUMP_ABSOLUTE JUMP_FORWARD COME_FROM
"""
def customize_grammar_rules(self, tokens, customize):

View File

@@ -13,8 +13,8 @@ else:
read_write_global_ops = frozenset(('STORE_GLOBAL', 'DELETE_GLOBAL', 'LOAD_GLOBAL'))
read_global_ops = frozenset(('STORE_GLOBAL', 'DELETE_GLOBAL'))
# NOTE: we also need to check that he variable name is a free variable, not a cell variable.
nonglobal_ops = frozenset(('LOAD_DEREF', 'STORE_DEREF', 'DELETE_DEREF'))
# NOTE: we also need to check that the variable name is a free variable, not a cell variable.
nonglobal_ops = frozenset(('STORE_DEREF', 'DELETE_DEREF'))
# FIXME: this and find_globals could be paramaterized with one of the
# above global ops