elm / virtual-dom

The foundation of HTML and SVG in Elm.
https://package.elm-lang.org/packages/elm/virtual-dom/latest
BSD 3-Clause "New" or "Revised" License
209 stars 80 forks source link

Export from debugger fails erroneously on types that contain magic strings #97

Closed jamesmacaulay closed 7 years ago

jamesmacaulay commented 7 years ago

If your Msg type contains a type whose fully qualified name contains within it the name of one of the hardcoded "problem" types, it is treated as unserializable when it shouldn't be. Here is a minimal example that produces an error (when it shouldn't) if you try to export from a debugger session:

https://ellie-app.com/3bJBLXZYFqHa1/2

One of the nested types that needs to be serialized is GraphQL.Client.Http.RequestError, and unfortunately that name contains the string "Http.Request", which makes it fail the test here:

https://github.com/elm-lang/virtual-dom/blob/f2350652d4f6fe0bf8c60347c3c7eff8588bbded/src/VirtualDom/Metadata.elm#L119-L140

I think the linked code should be altered to use regular expressions instead of strings in the problemTable so that the ordinary named types can be wrapped in beginning-/end-of-string markers, while the function type "->" regex could be left alone or perhaps wrapped in word-boundary markers.

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.

evancz commented 7 years ago

Tracking in #98. Thanks for the report!