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

This commit is contained in:
Jasper Jenkins
2019-04-15 08:02:25 -07:00
committed by Andreas Rumpf
parent e2848ccd2b
commit a68c5662f2

View File

@@ -1105,6 +1105,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))