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 sometimes changes values from int to float #449

Closed
tomasol opened this issue Jun 2, 2020 · 2 comments · Fixed by #870
Closed

JSON.stringify sometimes changes values from int to float #449

tomasol opened this issue Jun 2, 2020 · 2 comments · Fixed by #870
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution
Milestone

Comments

@tomasol
Copy link

tomasol commented Jun 2, 2020

When using functions like Math.round or Math.floor, type of the attribute seems seems to be float. This is not observable when inspecting the object, but is visible using JSON.stringify.
To Reproduce
Start CLI, enter

JSON.stringify({foo:Math.round(1)})

Response: {"foo":1.0}.
Expected behavior
Expected response {"foo":1}.

Build environment:

  • boa version: master (87aea64)
  • OS: Ubuntu
  • Version: 20.04
  • Target triple: x86_64-unknown-linux-gnu
  • Rustc version: 1.43.1 (8d69840ab 2020-05-04)
@tomasol tomasol added the bug Something isn't working label Jun 2, 2020
@HalidOdat
Copy link
Member

This might be related to #413

@croraf
Copy link
Contributor

croraf commented Jun 18, 2020

A simpler (seems to be related) example is:

JSON.stringify(1.0)

which outputs 1.0 in Boa comparing to 1 in Chrome.

The spec leads to here for JSON.stringification of finite numbers https://tc39.es/ecma262/#sec-numeric-types-number-tostring

@Razican Razican added this to the v0.11.0 milestone Oct 14, 2020
@Razican Razican added builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution labels Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants