Skip to content

Commit

Permalink
fixes #9829 (#11849)
Browse files Browse the repository at this point in the history
(cherry picked from commit b73d097)
  • Loading branch information
krux02 authored and narimiran committed Aug 12, 2019
1 parent 47c965f commit 0367a1f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/vmgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2176,7 +2176,7 @@ proc optimizeJumps(c: PCtx; start: int) =
var d = i + c.code[i].jmpDiff
for iters in countdown(maxIterations, 0):
case c.code[d].opcode
of opcJmp, opcJmpBack:
of opcJmp:
d = d + c.code[d].jmpDiff
of opcTJmp, opcFJmp:
if c.code[d].regA != reg: break
Expand Down
15 changes: 15 additions & 0 deletions tests/vm/tmaxloopiterations.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
discard """
errormsg: "interpretation requires too many iterations; if you are sure this is not a bug in your code edit compiler/vmdef.MaxLoopIterations and rebuild the compiler"
"""

# issue #9829

macro foo(): untyped =
let lines = ["123", "5423"]
var idx = 0
while idx < lines.len():
if lines[idx].len() < 1:
inc(idx)
continue

foo()

0 comments on commit 0367a1f

Please sign in to comment.