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

Json.Decode.decodeString throws runtime for types with cyclic dependencies #653

Closed
tiziano88 opened this Issue Jul 1, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@tiziano88

tiziano88 commented Jul 1, 2016

System details:

Elm Platform 0.17.0
Chrome Version 51.0.2704.103 (64-bit)
Ubuntu Linux 14.04 LTS

Error:

Uncaught TypeError: Cannot read property 'tag' of undefined
runHelp @ test.elm:5165
runHelp @ test.elm:5286
run @ test.elm:5157
runOnString @ test.elm:5152
A2 @ test.elm:92
(anonymous function) @ test.elm:7185
(anonymous function) @ test.elm:7220

Reproducible with the following example (even pasting it in http://elm-lang.org/try):

https://gist.github.com/tiziano88/7beb26152275326eb77bf9f754f14d9d

(I cut it down considerably from the original project, now it seems to be the minimal configuration that reliably causes the error)

I suspect the issue is due to the circular type dependencies, even though only two of the type involved are aliases, and the other two are actual types.

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Jul 1, 2016

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.

process-bot commented Jul 1, 2016

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.

@tiziano88

This comment has been minimized.

Show comment
Hide comment
@tiziano88

tiziano88 Jul 1, 2016

Actually, I managed to simplify the example even more; now it only contains three actual types, with a cyclic dependency between them. I am actually not sure what the expected outcome should be in this case, but definitely not a runtime error.

tiziano88 commented Jul 1, 2016

Actually, I managed to simplify the example even more; now it only contains three actual types, with a cyclic dependency between them. I am actually not sure what the expected outcome should be in this case, but definitely not a runtime error.

@tiziano88 tiziano88 changed the title from Json.Decoder throws runtime error to Json.Decode.decodeString throws runtime for types with cyclic dependencies Jul 1, 2016

@tiziano88

This comment has been minimized.

Show comment
Hide comment
@tiziano88

tiziano88 Jul 1, 2016

Turns out, even a single recursive type and associated decoder is enough (see updated Gist).

tiziano88 commented Jul 1, 2016

Turns out, even a single recursive type and associated decoder is enough (see updated Gist).

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Jul 2, 2016

Contributor

See issue 873 in the elm-compiler repo, in particular also all the discussion there and in its linked references about the Json decoding special case.

Contributor

jvoigtlaender commented Jul 2, 2016

See issue 873 in the elm-compiler repo, in particular also all the discussion there and in its linked references about the Json decoding special case.

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Jul 2, 2016

Contributor

That is, elm/compiler#873 (comment) (indicating how to work around this for Json decoders specially).

Contributor

jvoigtlaender commented Jul 2, 2016

That is, elm/compiler#873 (comment) (indicating how to work around this for Json decoders specially).

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