Repository navigation
Fix takeLast(0) on a Seq of unknown size - #2313
Merged
bdurrer merged 1 commit intoNov 2, 2026
Merged
Conversation
`takeLast(0)` slices from `-0`. `sliceFactory` only caches a Seq of unknown size when `begin < 0 || end < 0`, which is false for `-0`, so `resolveBegin` got an undefined size and resolved `-0` to 0. The whole Seq came back instead of an empty one. `end` of `-0` had the same problem. Use `isNeg`, which the index resolution already uses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
@jdeniau What's the target of the "Output diff for TS files" job? Verifying prettier formatting? |
Member
|
@bdurrer the purpose is to check that a file migrated to TS has the same output (and runtime) than main. |
Contributor
|
Ah thanks for clearing that up. So yeah, LGTM, I'll approve this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
takeLast(0)returns the whole Seq when its size is unknown:#1245 fixed this for known sizes:
takeLast(0)callsslice(-0), andresolveIndextreats-0as negative throughisNeg. ButsliceFactorydecides whether to cache a Seq of unknown size withbegin < 0 || end < 0, which is false for-0, soresolveBegin(-0, undefined)comes out as 0 and the slice starts at the beginning.This uses
isNegfor that check (now exported fromTrieUtils). I applied it toendas well:slice(0, -0)on a Seq of unknown size returned[], while the same call on a Seq of known size returns everything; now both agree.Zipped Seqs of unknown size also need #2311 for this, since they couldn't be cached before.
The test in
__tests__/slice.tsfails onmainand passes with this change. The same check is on6.x.I used Claude Code to write this change.