elm / compiler

Compiler for Elm, a functional language for reliable webapps.
https://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
7.48k stars 658 forks source link

Type annotation crashes the compiler #2296

Open az5112 opened 1 year ago

az5112 commented 1 year ago

Quick Summary: I create a list with List.map. Annotating the type of the list crashes the compiler.

SSCCE

module Main exposing (..)

import Browser
import Html exposing (..)

type alias Model =
    Int

main =
    Browser.element
        { init = \() -> (50, Cmd.none)
        , view = \model -> div [] []
        , update = \msg model -> (model, Cmd.none)
        , subscriptions = \_ -> Sub.none
        }

asRow attrs children =
    let
        -- compiles fine if the type annotation is removed
        cells : List (Html msg) -- <<<<<<<<<<<< crashes the compiler
        cells = List.map asCell children
    in
    div attrs cells

asCell : Html msg -> Html msg
asCell node =
    div [] [node]

The error is:

Compiling ...elm: You ran into a compiler bug. Here are some details for the developers:

    msg [rank = 2]

Please create an <http://sscce.org/> and then report it
at <https://github.com/elm/compiler/issues>

CallStack (from HasCallStack):
  error, called at compiler/src/Type/Solve.hs:206:15 in main:Type.Solve

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

Additional Details

Looks similar to https://github.com/elm/compiler/issues/2295 reported two days ago.

github-actions[bot] commented 1 year ago

Thanks for reporting this! To set expectations:

Finally, please be patient with the core team. They are trying their best with limited resources.