Closed swelet closed 5 years ago
I had a similar bug, tried to get an SSCCE, dug down through layers of files pulling out what I could got to
module CompilerBug exposing (main)
import Browser
import Dict exposing (Dict)
import Graphql.Http
import Html exposing (Html, div, text)
import Json.Decode
import RemoteData exposing (RemoteData)
import Task
-- GraphQl stuff
type alias Error parsedData =
RawError parsedData Graphql.Http.HttpError
type RawError a b
= OnePart a
| TwoPart b
type HttpError
= BadUrl String
| Timeout
| NetworkError
-- | BadStatus Http.Metadata String
| BadPayload Json.Decode.Error
type alias CrashMessage a =
RemoteData (Error a) a
type Msg
= Oops (CrashMessage Int)
crashTheCompiler : Cmd Msg
crashTheCompiler =
Task.succeed (Oops (RemoteData.Success 123))
|> Task.perform identity
type alias Model =
Int
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
Oops response ->
( model, Cmd.none )
init : () -> ( Model, Cmd Msg )
init flags =
( 0, crashTheCompiler )
view : Model -> Html Msg
view model =
div []
[ text "Hello" ]
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
main =
Browser.element
{ init = init
, update = update
, view = view
, subscriptions = subscriptions
}
At that point if I swapped Graphql.Http.HttpError to the copy-pasted version without the Http Metadata it worked fine, putting the metadata back in meant I had to instal the elm/http package as a direct dependency, as soon as I did that the problem went away in all cases. The error message I was getting was:
elm.exe: Map.!: given key is not an element in the map
CallStack (from HasCallStack):
error, called at libraries\containers\Data\Map\Internal.hs:603:17 in containers-0.5.10.2:Data.Map.Internal
It only happened when I was compiling with --debug, without that it compiled fine.
Thank you for the SSCCE @swelet! I can confirm it locally.
I have been working on some architectural changes in the compiler, and one of the aspects was trying to use types to rule out this kind of error. So with my personal build, the error does not arise anymore:
~/Documents/compiler/dist/build/elm/elm make temp.elm --debug
Success! Compiled 1 module.
Main ───> index.html
There is still a bunch of testing needed before this can be released as 0.19.1, so thank you for your patience on this.
I get
Map.!: given key is not an element in the map
when compiling with Webpack. Elm Reactor works fine.
I trace it back to having the Html type in one of my Msg:s
SSCCE