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

Improve "uninitialised element" error message #231

Merged
merged 1 commit into from
Jan 16, 2020

Conversation

alexwl
Copy link
Contributor

@alexwl alexwl commented Dec 12, 2018

Compaction (http://hackage.haskell.org/package/ghc-compact-0.1.0.0/docs/GHC-Compact.html#v:compact) of an immutable vector may crash with the confusing "uninitialised element" error message #220:

module Main where

import qualified Data.Vector as V
import GHC.Compact

main :: IO ()
main = do
  c <- compact $ V.fromList [1, 2, 3]
  pure ()
*** Exception: Data.Vector.Mutable: uninitialised element

As far as I understand, there is no simple way to fix this. However, there is an easy workaround: use the force function.

This code doesn't crash:

c <- compact $ V.force $ V.fromList [1, 2, 3]

The PR adds a suggestion to use the force function in the error message.

…ement' error message

Compaction of an immutable vector may crash with the confusing 'uninitialised element' error message (haskell#220). The workaround is to use the 'force' function.
@cartazio
Copy link
Contributor

cartazio commented Dec 12, 2018 via email

@recursion-ninja
Copy link
Contributor

recursion-ninja commented Jul 9, 2019

Is this still mergable?

It would help a user of both vector & compact packages with debugging diagnostics.

@cartazio
Copy link
Contributor

cartazio commented Jul 9, 2019 via email

@enobayram
Copy link

I wish this PR were merged and released. Would've saved us many hours of debugging.

@cartazio
Copy link
Contributor

cartazio commented Jan 15, 2020 via email

@enobayram enobayram mentioned this pull request Jan 15, 2020
@enobayram
Copy link

Thanks, I believe that's what you meant.

@recursion-ninja
Copy link
Contributor

Thanks, I've lost well over 40 man-hours getting bitten by this multiple times, usually in a trasitive dependency. It will be nice to get a moderately useful error message.

@cartazio cartazio merged commit fd35bac into haskell:master Jan 16, 2020
nh2 added a commit to nh2/vector that referenced this pull request Aug 11, 2020
Follow-up to PR haskell#231.

Users could easily be misled that it's `Control.DeepSeq.force`, not `Data.Vector.force`,
and the former does not fix the issue at all.
nh2 added a commit to nh2/vector that referenced this pull request Aug 11, 2020
Follow-up to PR haskell#231.

Users could easily be misled that it's `Control.DeepSeq.force`, not `Data.Vector.force`,
and the former does not fix the issue at all.
lehins pushed a commit that referenced this pull request Jan 16, 2021
Follow-up to PR #231.

Users could easily be misled that it's `Control.DeepSeq.force`, not `Data.Vector.force`,
and the former does not fix the issue at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants