3.5, 3.6 loop if/continue handling

This commit is contained in:
rocky
2018-03-28 09:23:34 -04:00
parent e568d68baa
commit 94a81a36b7
3 changed files with 19 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,13 @@
# From 3.6.4 pathlib.py
# Bug was handling "continue" as last statement of "if"
# RUNNABLE!
def parse_parts(it, parts):
for part in it:
if not part:
continue
parts = 1
return parts
assert parse_parts([], 5) == 5
assert parse_parts([True], 6) == 1
assert parse_parts([False], 6) == 6

View File

@@ -111,6 +111,12 @@ class Python35Parser(Python34Parser):
jump_absolute_else ::= jb_else
jump_absolute_else ::= CONTINUE ELSE
# Our hacky "ELSE" determination doesn't do a good job and really
# determine the start of an "else". It could also be the end of an
# "if-then" which ends in a "continue". Perhaps with real control-flow
# analysis we'll sort this out. Or call "ELSE" something more appropriate.
_ifstmts_jump ::= c_stmts_opt ELSE
# ifstmt ::= testexpr c_stmts_opt
iflaststmt ::= testexpr c_stmts_opt JUMP_FORWARD