Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upStop toString from descending into arbitrary objects #424
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Oct 11, 2015
Member
Yes, it was removed because records no longer have a _ field that distinguishes them.
Can you give concrete examples of values that mess this up?
|
Yes, it was removed because records no longer have a Can you give concrete examples of values that mess this up? |
evancz
closed this
Oct 11, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ThomasWeiser
Oct 12, 2015
Contributor
Ah, didn't know about the dropped _ field.
My example is a test app for elmfire. The native code returns a reference to internal data of the Firebase library. This data happens to have a cyclic structure.
I now have a workaround, where I drop this cyclic Json data from the record before printing.
Does this mean that cyclic structures are disallowed as a Json.Encode.Value? This would be kind of a burden for native wrappers around JS libraries. But it would be a valid argument to not have to do cycle checks in functions like toString (and probably in comparing and equality checking too).
|
Ah, didn't know about the dropped My example is a test app for elmfire. The native code returns a reference to internal data of the Firebase library. This data happens to have a cyclic structure. I now have a workaround, where I drop this cyclic Json data from the record before printing. Does this mean that cyclic structures are disallowed as a |
ThomasWeiser commentedOct 11, 2015
The function
toStringhas code to convert Elm-records into a string representation.This code missed a checked whether the JS object is really an Elm-record.
Problem: If toString is called on an recursively linked JS object (not an Elm-record, e.g. from a native library function), this will lead into an infinite recursion.
The check used to be in the code up to commit 08bf809. I don't know if Evan removed it intentionally for some reason.