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.stringify correctness issue #112

Closed
mathiasbynens opened this issue Jan 4, 2019 · 3 comments
Closed

JSON.stringify correctness issue #112

mathiasbynens opened this issue Jan 4, 2019 · 3 comments

Comments

@mathiasbynens
Copy link

$ eshost -x 'var allString = true; JSON.stringify([1,2,3,4,5], function(k,v){allString = allString && (typeof k == "string"); return v}); print(allString)'
#### Chakra
true

#### JavaScriptCore
true

#### SpiderMonkey
true

#### V8
true

#### V8 --harmony
true

#### XS
false
@mathiasbynens
Copy link
Author

Another one:

$ eshost -x 'var replaceTracker; function replaceFunc(key, value) { replaceTracker += key + "("+(typeof key)+")" + JSON.stringify(value) + ";"; return value; } replaceTracker = ""; JSON.stringify([1,2,3,,,,4,5,6], replaceFunc); print(replaceTracker);'
#### Chakra
(string)[1,2,3,null,null,null,4,5,6];0(string)1;1(string)2;2(string)3;3(string)undefined;4(string)undefined;5(string)undefined;6(string)4;7(string)5;8(string)6;

#### JavaScriptCore
(string)[1,2,3,null,null,null,4,5,6];0(string)1;1(string)2;2(string)3;3(string)undefined;4(string)undefined;5(string)undefined;6(string)4;7(string)5;8(string)6;

#### SpiderMonkey
(string)[1,2,3,null,null,null,4,5,6];0(string)1;1(string)2;2(string)3;3(string)undefined;4(string)undefined;5(string)undefined;6(string)4;7(string)5;8(string)6;

#### V8
(string)[1,2,3,null,null,null,4,5,6];0(string)1;1(string)2;2(string)3;3(string)undefined;4(string)undefined;5(string)undefined;6(string)4;7(string)5;8(string)6;

#### V8 --harmony
(string)[1,2,3,null,null,null,4,5,6];0(string)1;1(string)2;2(string)3;3(string)undefined;4(string)undefined;5(string)undefined;6(string)4;7(string)5;8(string)6;

#### XS
(string)[1,2,3,null,null,null,4,5,6];0(number)1;1(number)2;2(number)3;3(number)undefined;4(number)undefined;5(number)undefined;6(number)4;7(number)5;8(number)6;

@patrick-soquet
Copy link
Contributor

Thank you much for the report. I committed a fix which should be published next week. Meanwhile xst 8.6.2 is available so you can test with eshost.

peterwmwong pushed a commit to peterwmwong/v8 that referenced this issue Jan 7, 2019
The reference implementation used in the tests does not fully match
the spec, so for the diverging cases we need to explicitly specify
the correct expectation.

Every single change in this patch has been verified against every
major JavaScript engine using eshost + jsvu. All implementations
match the spec (and the V8 implementation), with the following two
exceptions:

- One expectation was wrong because of a JavaScriptCore bug (that
  is, we inherited the incorrect expectation when importing the
  tests from WebKit). A comment was added for that one.
- This work resulted in the discovery of bugs in Moddable/XS:
  Moddable-OpenSource/moddable#112

Change-Id: I05d91d7acc5c8765e941fcd68c1086c2694c710c
Reviewed-on: https://chromium-review.googlesource.com/c/1396081
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58546}
@phoddie
Copy link
Collaborator

phoddie commented Jan 29, 2019

The fix is now committed.

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

No branches or pull requests

3 participants