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

Overflow in size hints in bundles #406

Open
Shimuuar opened this issue Aug 13, 2021 · 0 comments
Open

Overflow in size hints in bundles #406

Shimuuar opened this issue Aug 13, 2021 · 0 comments

Comments

@Shimuuar
Copy link
Contributor

Consider following program:

import qualified Data.Vector.Unboxed as U

main :: IO ()
main = do
  print $ U.take 4 $ U.generate (maxBound - 4) id
                U.++ U.generate (maxBound - 4) id

One could think that it will print [0,1,2,3] provided it will fuse. It however fails with.

overflow: Data.Vector.Fusion.Bundle.Size.checkedAdd: overflow: -10
CallStack (from HasCallStack):
  error, called at src/Data/Vector/Fusion/Bundle/Size.hs:56:7 in vector-0.13.0.1-KtkGVThkqZeLj5OVQdyUBP:Data.Vector.Fusion.Bundle.Size

This happens because computation of both exact vector length and upper bound on vector size throws error if it overflows Int. I wasn't able to craft example which overflows maximum bound on length which is much more realistic.

This issue is mostly to record that error on error on overflow could cause problems. I'd propose following semantics change: overflow for upper bound on vector size reverts to unbounded. Overflow for lower bound does cause error. (Note not expressible with current implementation of size)

Related: #388

Shimuuar added a commit to Shimuuar/vector that referenced this issue Sep 14, 2021
It turns out we don't exercise munstream in the test suite at all. (Easy check
is to replace definition with undefined and run test) This is to check
equivalence of all variants.

This is necessary for any changes to unstream machinery. Such as ones that
discussed in haskell#301, haskell#388, haskell#406
Shimuuar added a commit to Shimuuar/vector that referenced this issue Sep 26, 2021
It turns out we don't exercise munstream in the test suite at all. (Easy check
is to replace definition with undefined and run test) This is to check
equivalence of all variants.

This is necessary for any changes to unstream machinery. Such as ones that
discussed in haskell#301, haskell#388, haskell#406
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

No branches or pull requests

1 participant