Guard against calling split with an empty string as a separator. Fixes #5119
This commit is contained in:
parent
2bb49136de
commit
40d034b7e3
2 changed files with 24 additions and 0 deletions
19
tests/stdlib/tsplit2.nim
Normal file
19
tests/stdlib/tsplit2.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
discard """
|
||||
file: "tsplit2.nim"
|
||||
output: "true"
|
||||
"""
|
||||
import strutils
|
||||
|
||||
var s = ""
|
||||
for w in split("|abc|xy|z", {'|'}):
|
||||
s.add("#")
|
||||
s.add(w)
|
||||
|
||||
try:
|
||||
discard "hello".split("")
|
||||
echo "false"
|
||||
except ValueError:
|
||||
echo "true"
|
||||
|
||||
#OUT true
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue