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

toString isn't type safe for Html #560

Closed
emptyflash opened this Issue Apr 17, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@emptyflash

emptyflash commented Apr 17, 2016

Originally posted at elm/compiler#1347

I get a runtime error from this code

viewBoard : Address Action -> Board -> Html

view : Address Action -> Model -> Html
view address model =
  div
    [ containerStyle ]
    [ viewBoard address model.board
        |> toString
        |> text
    ]

The error given is Uncaught TypeError: Cannot use 'in' operator to search for 'ctor' in null coming from the generated toString function. I think this has something to do with the fact that typeof for null returns "object", but this line else if (type === 'object' && 'ctor' in v) throws an error if v is null.

Here's my generated code:

var view = F2(function (address,model) {
    return A2($Html.div,_U.list([containerStyle]),_U.list([$Html.text($Basics.toString(A2(viewBoard,address,model.board)))]));
});

I don't actually want to convert the Html to a string, the Elm code above was a mistake, but it seems like maybe the compiler could have caught or handled it.

If someone could point me in the right direction, I would be more than willing to fix this.

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Apr 17, 2016

Contributor

As I explained in the other repository, there is already an issue open on this in this repository here. It makes zero sense to have another issue open. So I'm closing this.

Contributor

jvoigtlaender commented Apr 17, 2016

As I explained in the other repository, there is already an issue open on this in this repository here. It makes zero sense to have another issue open. So I'm closing this.

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Apr 17, 2016

Contributor

The relevant issue is https://github.com/elm-lang/core/issues/488, and there is already a candidate PR about fixing it (https://github.com/elm-lang/core/pull/183).

Contributor

jvoigtlaender commented Apr 17, 2016

The relevant issue is https://github.com/elm-lang/core/issues/488, and there is already a candidate PR about fixing it (https://github.com/elm-lang/core/pull/183).

@emptyflash

This comment has been minimized.

Show comment
Hide comment
@emptyflash

emptyflash Apr 18, 2016

Ah, my bad, I misunderstood the corresponding issue part. Thanks for the references!

emptyflash commented Apr 18, 2016

Ah, my bad, I misunderstood the corresponding issue part. Thanks for the references!

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