Commit f9f5f561 authored by Stefan Behnel's avatar Stefan Behnel

fix off-by-one again: if-clause is only last when there is no else-clause

parent 5cb96330
...@@ -5732,7 +5732,9 @@ class IfStatNode(StatNode): ...@@ -5732,7 +5732,9 @@ class IfStatNode(StatNode):
def generate_execution_code(self, code): def generate_execution_code(self, code):
code.mark_pos(self.pos) code.mark_pos(self.pos)
end_label = code.new_label() end_label = code.new_label()
last = len(self.if_clauses) - 1 last = len(self.if_clauses)
if not self.else_clause:
last -= 1 # avoid redundant goto at end of last if-clause
for i, if_clause in enumerate(self.if_clauses): for i, if_clause in enumerate(self.if_clauses):
if_clause.generate_execution_code(code, end_label, is_last=i == last) if_clause.generate_execution_code(code, end_label, is_last=i == last)
if self.else_clause: if self.else_clause:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment