Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Normative: Permit BigInt(large Number) #138

Merged
merged 1 commit into from
Apr 12, 2018
Merged

Normative: Permit BigInt(large Number) #138

merged 1 commit into from
Apr 12, 2018

Conversation

littledan
Copy link
Member

Previously, the BigInt constructor used IsSafeInteger to check if a Number
is safe to cast to a BigInt without losing information. This check is
unnecessarily conservative--it rules out large integer-valued Numbers.
This patch switches to just check that the Number is an integer value.

This patch specifies the resolution of the discussion in the March
2018 TC39 meeting.

Closes #132

spec.html Outdated
<emu-alg>
1. Assert: Type(_number_) is Number.
1. If _number_ is *NaN*, *+&infin;*, or *-&infin;*, return *false*.
1. Let _integer_ be ! ToInteger(_number_).
1. If ! SameValueZero(_integer_, _number_) is *false*, return *false*.
1. If abs(_integer_) &le; 2<sup>53</sup>-1, return *true*.
1. Otherwise, return *false*.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This algorithm will never return true. I think you want this last step to return true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Thanks for catching this. That's what I get for pushing a PR late at night.

Previously, the BigInt constructor used IsSafeInteger to check if a Number
is safe to cast to a BigInt without losing information. This check is
unnecessarily conservative--it rules out large integer-valued Numbers.
This patch switches to just check that the Number is an integer value.

This patch specifies the resolution of the discussion in the March
2018 TC39 meeting.

Closes #132
@caiolima
Copy link
Collaborator

caiolima commented Apr 8, 2018

@littledan just to double check, this doesn't change the current behavior/tests in test 262, right?

@littledan
Copy link
Member Author

littledan commented Apr 8, 2018

@caiolima This is a normative change. I don't know whether there is a test262 test that hits this case. If there isn't any test to update, it'd be good to add a test for it.

@littledan
Copy link
Member Author

@caiolima Would you be interested in writing a test262 test for this change?

@littledan
Copy link
Member Author

@jakobkummerow has implemented this change in V8 at https://chromium-review.googlesource.com/c/v8/v8/+/1004120 . Now that it's been proven out to this degree, and we also have committee consensus, I'm landing this patch; I'm sure we'll catch up soon on test262 tests.

@littledan littledan merged commit c807743 into master Apr 12, 2018
kisg pushed a commit to paul99/v8mips that referenced this pull request Apr 16, 2018
Spec change: tc39/proposal-bigint#138

Bug: v8:6791
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: I7367273ed1e98971be3b277f6486333a96412185
Reviewed-on: https://chromium-review.googlesource.com/1004120
Commit-Queue: Jakob Kummerow <[email protected]>
Reviewed-by: Georg Neis <[email protected]>
Cr-Commit-Position: refs/heads/master@{#52611}
anba added a commit to anba/test262 that referenced this pull request Apr 24, 2018
- "CannotSuspendMainAgent" feature was changed to "CanBlockIsFalse" flag
- Move annex-b tests into annex-b directory
- Update variable names in nonshared-int-views.js tests
- Move getReport() call in nan-for-timeout.js to avoid iloop
- Update BigInt constructor to match new semantics (tc39/proposal-bigint#138)
@littledan
Copy link
Member Author

Tests were landed in tc39/test262#1514

chicoxyzzy pushed a commit to chicoxyzzy/test262 that referenced this pull request May 14, 2019
- "CannotSuspendMainAgent" feature was changed to "CanBlockIsFalse" flag
- Move annex-b tests into annex-b directory
- Update variable names in nonshared-int-views.js tests
- Move getReport() call in nan-for-timeout.js to avoid iloop
- Update BigInt constructor to match new semantics (tc39/proposal-bigint#138)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants