Skip to content

Commit 5edcc7c

Browse files
committed
Remove restriction that there are no more statements after a "return" statement
1 parent 567dd78 commit 5edcc7c

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

test/bytecode_2.7/05_deadcode.pyc

311 Bytes
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Test to see we can a program that has dead code in it.
2+
# This was issue #150
3+
def func(a):
4+
if a:
5+
return True
6+
something_never_run()

uncompyle6/parsers/parse2.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def customize_grammar_rules(self, tokens, customize):
505505

506506
self.check_reduce['aug_assign1'] = 'AST'
507507
self.check_reduce['aug_assign2'] = 'AST'
508-
self.check_reduce['_stmts'] = 'AST'
508+
# self.check_reduce['_stmts'] = 'AST'
509509

510510
# Dead code testing...
511511
# self.check_reduce['while1elsestmt'] = 'tokens'
@@ -522,15 +522,6 @@ def reduce_is_invalid(self, rule, ast, tokens, first, last):
522522

523523
if lhs in ('aug_assign1', 'aug_assign2') and ast[0] and ast[0][0] == 'and':
524524
return True
525-
elif lhs == '_stmts':
526-
for i, stmt in enumerate(ast):
527-
if stmt == '_stmts':
528-
stmt = stmt[0]
529-
assert stmt == 'stmt'
530-
if stmt[0] == 'return':
531-
return i+1 != len(ast)
532-
pass
533-
return False
534525
return False
535526

536527
class Python2ParserSingle(Python2Parser, PythonParserSingle):

0 commit comments

Comments
 (0)