Fix: Tail with optional, readonly and non-tuple arrays#424
Merged
Beraliv merged 4 commits intoDec 5, 2024
Merged
Conversation
Collaborator
|
Hey @som-sm! I'll come back to you later today, apologies for late responses |
Beraliv
reviewed
Dec 3, 2024
Beraliv
reviewed
Dec 3, 2024
b1213c5 to
f32ecf8
Compare
Collaborator
|
@som-sm please finalise your changes and I'll be happy to get it merged |
Beraliv
reviewed
Dec 3, 2024
Beraliv
approved these changes
Dec 3, 2024
Contributor
Author
|
@Beraliv PR is finalised now, can be merged! I'll see if |
2 tasks
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.
PR Checklist
Overview
I came across this issue in
type-festregarding their implementation ofTail, which doesn't work as expected when instantiated with an array of all optional elements. Our implementation ofTailalso fails in this case; when instantiated with[1?, 2?, 3?], it returnsneverinstead of the expected[2?, 3?].Additionally, there are two other issues with the current implementation:
Tailincorrectly returnsneverwhen instantiated withreadonlyarrays.string[]),Tailcurrently returnsnever. I believe it should instead return back the same type, e.g.,Tail<string[]>should returnstring[]. However, in this scenario,type-festalso returns an empty array, which is kinda equivalent to our version ofnever, though I'm unsure why.@Beraliv If you think we should continue to return
neverfor non-tuple arrays, then the solution I proposed here should work.