Add len check for newIfStmt to avoid segfault (#11032)
This commit is contained in:
parent
e2848ccd2b
commit
a68c5662f2
1 changed files with 2 additions and 0 deletions
|
|
@ -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))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue