elm-lang / elm-make

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

Type error inside if statement for compiled JS #94

Closed athanclark closed 8 years ago

athanclark commented 8 years ago

This whole project build carries the bug for me (sorry in advance for not shrinking the problem set to something clearly reproducible): https://github.com/athanclark/cooperate-frontend/tree/cd6cc501c97ddda4445b4d054760f0c5f88963fa

This is the line I'm getting the error: https://github.com/athanclark/cooperate-frontend/blob/cd6cc501c97ddda4445b4d054760f0c5f88963fa/dist/App.js#L1289

The interesting thing is that the bug only arises when I use Debug.log - specifically on this line: https://github.com/athanclark/cooperate-frontend/blob/cd6cc501c97ddda4445b4d054760f0c5f88963fa/src/Root.elm#L76 - if you remove this log, the in error goes away (but still leaves me with a UX bug, for some reason my effects aren't causing actions for this modal).

This was all on version 0.16.0

athanclark commented 8 years ago

My mistake, this error should be moved to elm-compiler ><

athanclark commented 8 years ago

So apparently v (the argument to toString) is actually null in this case - that's why it passes the type === 'object' test first, but fails on property lookup. Why might the argument be null? hmm...

athanclark commented 8 years ago

So I found the offending line: https://github.com/athanclark/cooperate-frontend/blob/cd6cc501c97ddda4445b4d054760f0c5f88963fa/dist/App.js#L13284

So from my browser's stack trace, A2 (apply 2 param) is working fine, and so is log(): https://github.com/athanclark/cooperate-frontend/blob/cd6cc501c97ddda4445b4d054760f0c5f88963fa/dist/App.js#L4833. This is so confusing, because it's obvious that the second parameter to log(), and thus toString is an object literal. :S

jvoigtlaender commented 8 years ago

Well, the second parameter to log() there is an object literal, right, but then the toString implementation will recursively walk into the components of that object and try to print those. Among other things, it will thus try to print the result of this call: A2($Effects.map,ModalsAction,eff). You could try to reduce your case to find out whether that is actually the problematic thing.

jvoigtlaender commented 8 years ago

Or, actually, it seems that the other component, the model, contains some Html deep inside (at least at one place, in the PersonModel type). And, well, toString doesn't work on Html values. See https://github.com/elm-lang/core/issues/488.

athanclark commented 8 years ago

This was my exact issue - calling toString (x :: Html), sorry about this.