The following program:
module Main where
broken : (Int, Int) -> Int
broken (model, action) = Debug.crash ""
consistently causes an internal compiler error in elm 0.16 (at least on my and one of my coworker's Macs). The error message is:
$ rm -rf elm-stuff/ index.html build/
$ elm-make TestMain.elm --yes
Downloading elm-lang/core
Packages configured successfully!
[=========================================== ] - 28 / 32elm-make: the annotation added in 'depattern' should not be observed!
elm-make: thread blocked indefinitely in an MVar operation
where TestMain.elm contains the code above.
Both the tuple pattern match and the call to Debug.crash seem to be necessary. In particular, if you replace (model, action) with a simple variable the problem goes away. Also if you replace Debug.crash with another function of the same type, the problem goes away. For instance, this program:
module Main where
any : String -> a
any a = any a
broken : (Int, Int) -> Int
broken (model, action) = any ""
compiles without error.
I believe this is an elm-compiler issue rather than an elm-make issue because the error message the annotation added in 'depattern' should not be observed! is from the elm compiler (https://github.com/elm-lang/elm-compiler/blob/master/src/Optimize.hs#L391). Apologies if it should be filed with elm-make or somewhere else.
This is also reproducible with record deconstruction, and in 0.17.
Here are two SCCEs that reproduce in try-elm 0.17:
fn ( x, y ) = Debug.crash ""
fn { x, y } = Debug.crash ""
Output of both is:
elm-make: the annotation added in 'depattern' should not be observed!
elm-make: thread blocked indefinitely in an MVar operation
I just ran into this when I tried to do this:
Time.now |> Task.perform (\() -> Debug.crash "oh no!") Tick
changing this to
Time.now |> Task.perform (\_ -> Debug.crash "oh no!") Tick
does not produce the error.
(\() -> ... was replaced by \_ -> ...)
Another SCCE that triggers the same error in 0.18:
type Foo a
= Foo a
broken : Foo a -> a
broken (Foo a) =
Debug.crash "not implemented"
I found a simple workaround.
broken : (Int, Int) -> Int
broken (model, action) = Debug.crash "" ()
Appears to be the same issue as https://github.com/elm-lang/elm-make/issues/157
This goes through without problems in my development build, so this should be fixed in the next release. Thank you for reporting this very weird case!
Most helpful comment
I found a simple workaround.