Skip to content
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.parse call is stripped from the output ( Reproducible ) #1775

Closed
thetutlage opened this issue Dec 4, 2017 · 4 comments · Fixed by #1785
Closed

JSON.parse call is stripped from the output ( Reproducible ) #1775

thetutlage opened this issue Dec 4, 2017 · 4 comments · Fixed by #1785

Comments

@thetutlage
Copy link

thetutlage commented Dec 4, 2017

Haven't find any existing issue for same. Sharing the REPL example, where JSON.parse statement has been removed from the code.

Reproduce here

@adrianheine
Copy link
Contributor

This is wrong, but to be expected, since JSON.parse is marked as a pure function.

@lukastaegert
Copy link
Member

I agree, maybe marking JSON.parse as pure was wrong since throwing errors is part of its interface. Note that this call is only removed because you are not reusing the result. Still, I think this should be changed and we should add a small test similar to your example so that this use case is not forgotten.

@adrianheine
Copy link
Contributor

JSON.stringify throws on circular structures, so maybe that's not pure either?

@lukastaegert
Copy link
Member

I get a feeling there is some thin line here we might cross at some point but yes, I guess you are correct. I think once we implement /*#IMPURE*/ annotations, see #1771 , we might at the same time finally start parsing /*#PURE*/ annotations so that people can make their JSON interactions tree-shakeable again.

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

Successfully merging a pull request may close this issue.

3 participants