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

Fix runtime error when testing equality of Json.Encode.null values #294

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@ThomasWeiser
Contributor

ThomasWeiser commented Jul 14, 2015

Function eq in Utils.js is currently only suitable for normal Elm types, not for arbitrary (speak Json.Encode) values.

As a result, comparing Json.Encode.nullwith anything non-null throws a runtime error.

Example:

Json.Encode.null == Json.Encode.object []

This PR fixes these cases.

Unit-tests are added to tests/Test/Equality.elm

@ThomasWeiser ThomasWeiser referenced this pull request Jul 14, 2015

Closed

List of known runtime errors #913

1 of 7 tasks complete
@ThomasWeiser

This comment has been minimized.

Show comment
Hide comment
@ThomasWeiser

ThomasWeiser Oct 11, 2015

Contributor

Rebased to current master.
Ready for being merged for upcoming relase 3.0.0

Contributor

ThomasWeiser commented Oct 11, 2015

Rebased to current master.
Ready for being merged for upcoming relase 3.0.0

Fix runtime error when testing equality of Json.Encode.null values
Function `eq` in Utils.js is currently only suitable for normal Elm types, not for arbitrary (speak `Json.Encode`) values.
As a result, comparing `Json.Encode.null`with anything non-null throws a runtime error.
This commit fixes these cases.

Unit-tests are added to tests/Test/Equality.elm
@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Jun 25, 2016

Member

6f5fbb8 does a check like this, and 1c00777 makes a note that it will not be possible to check for equality on Json.Encode.Value once a proper fix is implemented. That scenario is fundamentally problematic because a Json.Encode.Value can come through ports, meaning it can have functions.

This issue blocked because it was not clear what the ultimate fix would be. Now that it is clearer, I am fine with doing the stopgap.

Member

evancz commented Jun 25, 2016

6f5fbb8 does a check like this, and 1c00777 makes a note that it will not be possible to check for equality on Json.Encode.Value once a proper fix is implemented. That scenario is fundamentally problematic because a Json.Encode.Value can come through ports, meaning it can have functions.

This issue blocked because it was not clear what the ultimate fix would be. Now that it is clearer, I am fine with doing the stopgap.

@evancz evancz closed this Jun 25, 2016

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