Summary
split('a,b,c', ',', -1) returns [] — the input is discarded. RFC 0006 documents
maxsplit as splitting "at most maxsplit times" and defines nothing for a negative value,
so no reading supports returning an empty list. Python (whose str.split the function
otherwise follows) treats a negative maxsplit as "unlimited", returning ["a", "b", "c"].
Versions
openjd-model 0.11.1 and 0.11.2 from PyPI
openjd-rs main at 1a89f3a — still reproduces
Reproduction
from openjd.expr import parse_expression
for src in ("split('a,b,c', ',', -1)", "rsplit('a,b,c', ',', -1)"):
r = parse_expression(src).evaluate_with_metrics()
print(src, "->", str(r.value)) # -> [] for both
Expected vs actual
| Expression |
Expected |
Actual |
split('a,b,c', ',', -1) |
["a", "b", "c"] (Python's reading) or an error |
[] |
rsplit('a,b,c', ',', -1) |
["a", "b", "c"] or an error |
[] |
Either the Python reading or an explicit rejection would be defensible; silently returning
[] loses data with no textual support in the spec.
Summary
split('a,b,c', ',', -1)returns[]— the input is discarded. RFC 0006 documentsmaxsplitas splitting "at mostmaxsplittimes" and defines nothing for a negative value,so no reading supports returning an empty list. Python (whose
str.splitthe functionotherwise follows) treats a negative
maxsplitas "unlimited", returning["a", "b", "c"].Versions
openjd-model0.11.1 and 0.11.2 from PyPIopenjd-rsmainat1a89f3a— still reproducesReproduction
Expected vs actual
split('a,b,c', ',', -1)["a", "b", "c"](Python's reading) or an error[]rsplit('a,b,c', ',', -1)["a", "b", "c"]or an error[]Either the Python reading or an explicit rejection would be defensible; silently returning
[]loses data with no textual support in the spec.