You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
codegen: String.prototype.split rejects 2-arg form (separator, limit) #567
to split "key=value=with=equals" into ["key", "value=with=equals"] (or just ["key"] if no =). Without the limit, = characters inside the value get lost. This is the standard idiom for parsing query-string-style key/value pairs and it's a hard requirement for AWS SigV4 canonicalization.
Suggested implementation
String.prototype.split is currently lowered in crates/perry-codegen/src/lower_string_method.rs (or similar — search for the error message string). Extend the call site to accept a 2nd argument limit: number. Two reasonable shapes:
Honor it precisely (per spec): split fully, then truncate the resulting array to limit entries.
Honor a trimmed form: split until limit substrings are produced and stop scanning.
Either is fine for spec-conformance — [].split(sep, n) and bun/Node both implement option (1) since it's simpler and the result is identical.
For RegExp separators, behavior should match the string-separator path (since perry already supports regex .split(re) per other recent fixes).
Acceptance
The repro at the top prints a / b / 2 — matching Node/bun byte-for-byte.
Codegen-side gap closed in v0.5.661 (commit 403b1d6) — String.split(s, limit) now compiles AND runs. Repro from the issue prints a / b / 2 matching Node; edge cases (limit=0, limit > parts, regex separator with limit) all match byte-for-byte.
Activity
proggeramlug commentedon May 7, 2026
Codegen-side gap closed in v0.5.661 (commit 403b1d6) —
String.split(s, limit)now compiles AND runs. Repro from the issue printsa / b / 2matching Node; edge cases (limit=0,limit > parts, regex separator with limit) all match byte-for-byte.