From 66660eca320eb4e136f2673603e0cb799531a0f1 Mon Sep 17 00:00:00 2001 From: narimiran Date: Thu, 4 Jul 2019 12:02:35 +0200 Subject: [PATCH] nimpretty: fix out of bounds error [ci skip] (cherry picked from commit 4450fca6fdf3b0218783f0615a62e64ab93be550) --- compiler/layouter.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/layouter.nim b/compiler/layouter.nim index 7d0152122c..724e827cc6 100644 --- a/compiler/layouter.nim +++ b/compiler/layouter.nim @@ -250,8 +250,9 @@ proc wrTab(em: var Emitter) = wr(em, " ", ltTab) proc beginSection*(em: var Emitter) = - em.tokens.insert "", em.tokens.len-2 - em.kinds.insert ltBeginSection, em.kinds.len-2 + let pos = max(0, em.tokens.len-2) + em.tokens.insert "", pos + em.kinds.insert ltBeginSection, pos #wr(em, "", ltBeginSection) proc endSection*(em: var Emitter) =