elm-lang / elm-make

A build tool for Elm projects
BSD 3-Clause "New" or "Revised" License
175 stars 45 forks source link

[alpha] Runtime exception with --debug when Json.Encode.null in init #122

Closed simonh1000 closed 7 years ago

simonh1000 commented 7 years ago

Using Ubuntu 16.04, and 0.18 alpha.

The code below (initialising with null) fails to start and causes an exception, while using the commented out section (with string) works fine.

module Test exposing (main)

import Html exposing (..)
import Json.Encode as E exposing (Value)

-- MODEL

type alias Model =
    { gmap : Value
    }

init : (Model, Cmd Msg)
init =
    ( Model E.null, Cmd.none )
    -- ( Model (E.string "Dummy text"), Cmd.none )

-- UPDATE
type Msg
    = North

update : Msg -> Model -> (Model, Cmd Msg)
update message model =
    model ! []
-- VIEW

view : Model -> Html Msg
view model =
    text "hello world"

main =
  Html.program
    { init = init
    , update = update
    , view = view
    , subscriptions = always Sub.none
    }

[If the fix is not to test for null values, then note that in my code that originally ran into this bug, just fixing the init value to use Encode.string "dummy string" was not enough, as I got another null value being passed to init (which I have not tracked down yet) - see https://github.com/simonh1000/elm-google-maps-2]

process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

evancz commented 7 years ago

Thanks for the report, should be fixed if you get rid of elm-stuff/ and rebuild!