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

Compiler error: index out of bound (3,3) somewhere in Data/Vector/Generic/Mutable.hs #2148

Open
ggarek opened this issue Nov 2, 2020 · 1 comment

Comments

@ggarek
Copy link

ggarek commented Nov 2, 2020

Quick Summary:

I stumbled upon this compiler error.

Compiling ...elm: ./Data/Vector/Generic/Mutable.hs:703 (modify): index out of bounds (3,3)
CallStack (from HasCallStack):
  error, called at ./Data/Vector/Internal/Check.hs:87:5 in vector-0.12.0.3-FaW0AndQgt0BzgPSs4kvRl:Data.Vector.Internal.Check
Complete compiler output
Compiling ...elm: ./Data/Vector/Generic/Mutable.hs:703 (modify): index out of bounds (3,3)
CallStack (from HasCallStack):
  error, called at ./Data/Vector/Internal/Check.hs:87:5 in vector-0.12.0.3-FaW0AndQgt0BzgPSs4kvRl:Data.Vector.Internal.Check

-- ERROR -----------------------------------------------------------------------

I ran into something that bypassed the normal error reporting process! I
extracted whatever information I could from the internal error:

>   thread blocked indefinitely in an MVar operation

These errors are usually pretty confusing, so start by asking around on one of
forums listed at https://elm-lang.org/community to see if anyone can get you
unstuck quickly.

-- REQUEST ---------------------------------------------------------------------

If you are feeling up to it, please try to get your code down to the smallest
version that still triggers this message. Ideally in a single Main.elm and
elm.json file.

From there open a NEW issue at https://github.com/elm/compiler/issues with your
reduced example pasted in directly. (Not a link to a repo or gist!) Do not worry
about if someone else saw something similar. More examples is better!

This kind of error is usually tied up in larger architectural choices that are
hard to change, so even when we have a couple good examples, it can take some
time to resolve in a solid way.elm: thread blocked indefinitely in an MVar operation

SSCCE

The simple reproducible example turned out to be pretty obfuscated.

module Main exposing (..)

import Html exposing (Html)


type alias A =
    { ap1 : String }


type alias B =
    { bp1 : String }


type alias Model =
    {}


type Msg
    = Noop


main : Html Msg
main =
    Html.div [] []


f1 : Model -> Model
f1 model =
    let
        ( a, b ) =
            List.foldr
                (\x ( a2, list ) ->
                    case x.d of
                        Nothing ->
                            ( a2, x :: list )

                        Just c ->
                            let
                                c2 =
                                    { c | p1 = c.p1 + 1 }

                                x2 =
                                    { x | c = Just c2 }

                                ( a3, x3 ) =
                                    f2 a2 x2
                            in
                            ( a3, x3 :: list )
                )
                ( model.a, [] )
                model.b
    in
    { model | a = a, b = b }


f2 : A -> B -> ( A, B )
f2 x y =
    ( x, y )
  • Elm: 0.19.1
  • Browser: Well, the error happens before the code can see the browser.
  • Operating System: macOS Catalina 10.15.7

Additional Details

I found a way around the error, in fact it seems to be caused by the wrong property name in the assignment expression. I can't post the original code though, so although the provided example results in the same error it can't be fixed the same way.

In the original code I had something like { mything | prop = newProp }, where mything didn't have prop.

I realize that this report is super confusing, but atm I don't think I can make it any clearer 🙁.

@supermacro
Copy link

I just ran into this issue.

https://github.com/parlez-vous/embed/blob/d5fa2ba889863bf648488ed8515fe283c5592acb/src/elm/ParlezVousEmbed.elm#L155

The second argument to Dict.union is invalid.

commentTree is a record of the following type:

type alias CommentTree =
    { comments : CommentMap
    , topLevelComments : List Cuid
    , siteVerified : Bool
    , postId : String
    }

Changing that line of code to be Dict.union subCommentTree.comments commentTree.comments eliminates the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants