mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 22:33:49 +00:00
Add len check for newIfStmt to avoid segfault (#11032)
(cherry picked from commit a68c5662f2)
This commit is contained in:
committed by
narimiran
parent
15c526c298
commit
f575cdc1ae
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user