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

builtins.toJSON: fix __toString usage #3167

Merged
merged 1 commit into from Oct 27, 2019

Conversation

globin
Copy link
Member

@globin globin commented Oct 27, 2019

Fixes the evaluation of an attrs using __toString with builtins.toJSON:

Before:

nix-repl> builtins.toJSON { __toString = _: "foo"; }
error: cannot convert a function to JSON

Now:

nix-repl> builtins.toJSON { __toString = _: "foo"; }
"\"foo\""

I tried to abstract this away a bit to not duplicate the logic.

Also I'm not happy about the noPos in the toJSON case, but I couldn't figure out how to get a correct Pos and I think that shouldn't be shown anyway.

cc @Ericson2314 who helped me find the error

globin added a commit to NixOS/nixpkgs that referenced this pull request Oct 27, 2019
@edolstra edolstra merged commit e583df5 into NixOS:master Oct 27, 2019
@globin globin deleted the tojson-tostring-fix branch October 27, 2019 12:26
globin added a commit to NixOS/nixpkgs that referenced this pull request Oct 30, 2019
jtojnar pushed a commit to NixOS/nixpkgs that referenced this pull request Dec 30, 2019
jtojnar pushed a commit to NixOS/nixpkgs that referenced this pull request Dec 30, 2019
jtojnar pushed a commit to NixOS/nixpkgs that referenced this pull request Dec 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants