summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorRyan McConnell <rammcconnell@gmail.com>2023-07-20 13:56:54 -0400
committerGitHub <noreply@github.com>2023-07-20 19:56:54 +0200
commit2f817ee5b45db3a7152b87e6921188afd65486cc (patch)
tree01d3cf7482787fc7e11a5fc8f75003fd419cb045
parent3f9e16594fb26b78f812094a86d5e269093d8034 (diff)
downloadNim-2f817ee5b45db3a7152b87e6921188afd65486cc.tar.gz
`infixArgument` fail in `renderer.nim` sometimes (#22264)
* fixing minor typo

* Adding err msg
-rw-r--r--compiler/renderer.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/renderer.nim b/compiler/renderer.nim
index ac4ff2a77..b9c3268c4 100644
--- a/compiler/renderer.nim
+++ b/compiler/renderer.nim
@@ -1038,7 +1038,7 @@ proc accentedName(g: var TSrcGen, n: PNode) =
     gsub(g, n)
 
 proc infixArgument(g: var TSrcGen, n: PNode, i: int) =
-  if i < 1 and i > 2: return
+  if i < 1 or i > 2: return
   var needsParenthesis = false
   let nNext = n[i].skipHiddenNodes
   if nNext.kind == nkInfix:
@@ -1382,6 +1382,10 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext, fromStmtList = false) =
     putWithSpace(g, tkColon, ":")
     gsub(g, n, 1)
   of nkInfix:
+    if n.len < 3:
+      var i = 0
+      put(g, tkOpr, "Too few children for nkInfix")
+      return
     let oldLineLen = g.lineLen # we cache this because lineLen gets updated below
     infixArgument(g, n, 1)
     put(g, tkSpaces, Space)