Add len check for newIfStmt to avoid segfault (#11032)

(cherry picked from commit a68c5662f2)
This commit is contained in:
Jasper Jenkins
2019-04-15 08:02:25 -07:00
committed by narimiran
parent 15c526c298
commit f575cdc1ae

View File

@@ -976,6 +976,8 @@ proc newIfStmt*(branches: varargs[tuple[cond, body: NimNode]]):
## )
##
result = newNimNode(nnkIfStmt)
if len(branches) < 1:
error("If statement must have at least one branch")
for i in branches:
result.add(newTree(nnkElifBranch, i.cond, i.body))