Skip to content

Commit 61c91ce

Browse files
committed
Remove special handling of negative steps for generator iteration
This should throw an exception once they are implemented.
1 parent 43bfbd3 commit 61c91ce

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/transpiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,11 +1184,10 @@ def transpileStmtFor(self, node):
11841184
getter = v.Dereference(iterator, type=type.subtype)
11851185

11861186
self.cast(step_expr, step, t.Int)
1187-
abs_step = self.tmp(v.Call('std::abs', step, type=step.type))
11881187

11891188
if type.isGenerator():
11901189
cond = v.BinaryOp(v.Attribute(value, 'state'), '!=', -1)
1191-
update = v.Call(v.Attribute(value, 'next'), abs_step)
1190+
update = v.Call(v.Attribute(value, 'next'), step)
11921191
if type.subtype != t.Void:
11931192
update = v.CommaSequence(v.BinaryOp(getter, '=', update), cond)
11941193
else:
@@ -1197,6 +1196,7 @@ def transpileStmtFor(self, node):
11971196
index = self.tmp(v.Int(0), force_copy=True)
11981197
length = self.tmp(v.Call(v.Attribute(value, 'size'), type=t.Int))
11991198
cond = v.BinaryOp(index, '<', length)
1199+
abs_step = self.tmp(v.Call('std::abs', step, type=step.type))
12001200
update = v.CommaSequence(v.BinaryOp(index, '+=', abs_step),
12011201
# iterator should not cross the end of a container
12021202
v.TernaryOp(cond, v.CommaSequence(v.BinaryOp(iterator, '+=', step), v.true), v.false))

0 commit comments

Comments
 (0)