From 8fe1c8b1dd1f14b4af6077ea77ead77a6218046f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20D=C3=B6ring?= Date: Mon, 29 Jul 2019 16:13:19 +0200 Subject: [PATCH] fix #9829 --- compiler/vmgen.nim | 2 +- tests/vm/tmaxloopiterations.nim | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/vm/tmaxloopiterations.nim diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index a27cd62c68ca..d1ed78bf2ebc 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -2160,7 +2160,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 diff --git a/tests/vm/tmaxloopiterations.nim b/tests/vm/tmaxloopiterations.nim new file mode 100644 index 000000000000..6334d1e6dffd --- /dev/null +++ b/tests/vm/tmaxloopiterations.nim @@ -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()