Rework nil/option for nre in light of ""==nil

Fixes #9243
This commit is contained in:
Flaviu Tamas 2018-11-18 21:41:40 -05:00
commit c0a47f7e22
No known key found for this signature in database
GPG key ID: D6BF32C876496756
6 changed files with 126 additions and 87 deletions

View file

@ -16,5 +16,7 @@ suite "replace":
check("123".replace(re"(?<foo>\d)(\d)", "${foo}$#$#") == "1123")
test "replacing missing captures should throw instead of segfaulting":
expect ValueError: discard "ab".replace(re"(a)|(b)", "$1$2")
expect ValueError: discard "b".replace(re"(a)?(b)", "$1$2")
expect IndexError: discard "ab".replace(re"(a)|(b)", "$1$2")
expect IndexError: discard "b".replace(re"(a)?(b)", "$1$2")
expect KeyError: discard "b".replace(re"(a)?", "${foo}")
expect KeyError: discard "b".replace(re"(?<foo>a)?", "${foo}")