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

XS: JSON.parse passes wrong argument to reviver in base case when deleting properties #285

Open
bakkot opened this issue Nov 8, 2019 · 0 comments

Comments

@bakkot
Copy link

@bakkot bakkot commented Nov 8, 2019

The final invocation of the optional reviver argument to JSON.parse is passed as its two arguments the empty string and the object which has just been created. In XS, if the reviver has deleted every other property, the final invocation is instead passed some object (I'm not sure which), with no second argument.

function reviver(key, value) {
  console.log(JSON.stringify(key));
  console.log(JSON.stringify(value));
}

JSON.parse('{ "a": 0, "b": 1 }', reviver);

prints

"a"
0
"b"
1
""
{}

in every other engine, but in XS prints

"a"
0
"b"
1
{}
undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.