elm / core

Elm's core libraries
http://package.elm-lang.org/packages/elm/core/latest
BSD 3-Clause "New" or "Revised" License
2.79k stars 359 forks source link

Equality check on Json.Decode.oneOf always returns true #904

Open shuhei opened 7 years ago

shuhei commented 7 years ago

Currently any pair of oneOf decoders are equal in the equality check that is used for diffing in virtual-dom. Because of this, changes in oneOf decoders are not reflected in event handlers of DOMs. (An example on Ellie)

Equality of two oneOf decoders are checked with _Json_listEquality(), which expects JavaScript arrays of decoders. However, a oneOf decoder has an Elm List of decoders instead of a JavaScript Array. Because of this, the len variable below becomes undefined given oneOf decoders, and the function always returns true for oneOf decoders.

https://github.com/elm-lang/core/blob/bc067c8e3db20235fc275b1d825bb76f365a1509/src/Elm/Kernel/Json.js#L378-L398

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.