Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix splitV when splitting empty sequence to type [inf][0] #1750

Merged
merged 2 commits into from
Sep 18, 2024
Merged

Conversation

RyanGlScott
Copy link
Contributor

Previously, splitV would assume that if you were splitting a value val into something of type [inf][each], then val must be a stream of type of [inf * each] (i.e., of type [inf]). This is not true in the corner case where each equals 0, however. In that case, val is of type [0], which is a word, not a stream. As such, we need to ensure that we do not call fromSeq on val, which crashes if val is not a stream or sequence.

Fixes #1749.

I found the code in `splitV` hard to read, so this commit performs some mild
refactoring to improve things somewhat:

1. There are multiple cases where `parts` can be either `Nat` or `Inf`, but the
   two `Nat` cases were far away from each other visually (and similarly for the
   two `Inf` cases).
2. The code was pattern-matching on `each` for no good reason, as every case
   treated `each` as a bare variable. I've removed this match.

There is no change in behavior, just refactoring.
Previously, `splitV` would assume that if you were splitting a value `val` into
something of type `[inf][each]`, then `val` must be a stream of type of `[inf *
each]` (i.e., of type `[inf]`). This is not true in the corner case where
`each` equals `0`, however. In that case, `val` is of type `[0]`, which is a
word, not a stream. As such, we need to ensure that we do not call `fromSeq` on
`val`, which crashes if `val` is not a stream or sequence.

Fixes #1749.
@RyanGlScott RyanGlScott merged commit ee1378f into master Sep 18, 2024
48 checks passed
@RyanGlScott RyanGlScott deleted the T1749 branch September 18, 2024 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

not a sequence panic involving empty sequences
1 participant