haskell / haskell/vector

Overflow in size hints in bundles

未关闭
#406 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Haskell
星标
400
派生
145
PR 合并指标
30 天内没有已合并 PR

描述

Consider following program:

```haskell
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

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。