-
Notifications
You must be signed in to change notification settings - Fork 158
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
Editor review: type confusion around number types #1413
Comments
Thanks, I was afraid there might be a few places where this is still wrong. |
This is to be done comprehensively in #1413, but may as well fix these cases that were identified in review.
This is to be done comprehensively in #1413, but may as well fix these cases that were identified in review. (Comma separators are currently not used in the spec text, so prefer scientific notation if the numbers are large.)
Should note that while doing this issue, comma thousands separators are currently not used in the spec text. |
This is to be done comprehensively in #1413, but may as well fix these cases that were identified in review. (Comma separators are currently not used in the spec text, so prefer scientific notation if the numbers are large.)
This is to be done comprehensively in #1413, but may as well fix these cases that were identified in review. (Comma separators are currently not used in the spec text, so prefer scientific notation if the numbers are large.)
This is to be done comprehensively in #1413, but may as well fix these cases that were identified in review. (Comma separators are currently not used in the spec text, so prefer scientific notation if the numbers are large.)
This is to be done comprehensively in #1413, but may as well fix these cases that were identified in review. (Comma separators are currently not used in the spec text, so prefer scientific notation if the numbers are large.)
This is to be done comprehensively in #1413, but may as well fix these cases that were identified in review. (Comma separators are currently not used in the spec text, so prefer scientific notation if the numbers are large.)
This is to be done comprehensively in #1413, but may as well fix these cases that were identified in review. (Comma separators are currently not used in the spec text, so prefer scientific notation if the numbers are large.)
Note, make sure that all operations make clear what the number types of the inputs are, by assertions. |
These are not currently used in Ecma-262. Use scientific notation in these simple power-of-10 cases. See: #1413
These are not used anymore. See: #1413
…umbers As per #1413, internal fields should store mathematical values. Previously the internal slots of Temporal.Duration were described as integer Number values. Changing this also requires changing the return value of GetOffsetNanosecondsFor to an integer, because arithmetic is done on offset nanoseconds with Duration fields. Adds test262 tests covering the validation steps done at the end of GetOffsetNanosecondsFor, for all entry points that observably call Temporal.TimeZone.getOffsetNanosecondsFor(). See: #1413
These are not currently used in Ecma-262. Use scientific notation in these simple power-of-10 cases. See: #1413
These are not used anymore. See: #1413
This won't be a problem for most of Temporal, but @anba raised in #1534 (comment) that this requirement is a problem for Temporal.Duration's internal slots, because they are unbounded. This could make any future additional properties on Temporal.Duration unpolyfillable. @syg do you have any opinion on this? |
I don't quite understand the concern @anba raised. Why can't the polyfills use BigInts and convert them to Numbers at the boundary? |
If I'm understanding @anba correctly, suppose a new method was added to Duration in the future, which used the bigint values from the internal slots in its calculations. A polyfill wouldn't be able to correctly do this. |
Why wouldn't it? The polyfill would still store the bigint value internally, and its version of the new method would have access to those, no? (Separately, if the values are being stored as bigints/mathematical integers internally, why are they exposed as Numbers in the API?) |
Depends on whether the polyfill would replace the entire API or just add the new function, presumably. |
That’s a fair point; it would likely force a new method being polyfilled to also polyfill all of that Temporal type. |
Yes, I was concerned about the case when a possible Temporal v2 extends |
The patch from #1534 was only redefining that the internal slots are now stored as mathematical values instead of Number values. It didn't update any existing call sites to use |
Thanks for the explanation. The "do math on MVs, convert to Numbers at the boundary" is pretty pervasive in the spec. I don't feel like partial polyfilling is a use case that we ought to go out of our way to enable, especially for Temporal, one of whose main value adds is that we can start shipping this and the related data in browsers to cut down on payload size. So I'd rather not do anything different here, which could result in subtle arithmetic bugs and gotchas down the road. |
These are not currently used in Ecma-262. Use scientific notation in these simple power-of-10 cases. See: #1413
These are not used anymore. See: #1413
I think I agree that we should do all internal maths on MVs. My apologies for not realizing earlier that this would be a normative change in the Duration case. Any changes to the other classes should be purely editorial, thanks to the existing range checks, so we should be able to continue with those pending a plenary decision. |
I'd like to split off #1604 for the normative change to Duration, so that Ms2ger can close this when all of the other editorial issues are resolved. |
GetOption with Number type returns a Number value, so the fallback value should also be a Number value, and the result should be compared with Number values in the following step. Add a structured header, to make the types clear. See: #1413
GetOption with Number type returns a Number value, so the fallback value should also be a Number value, and the result should be compared with Number values in the following step. Add a structured header, to make the types clear. See: #1413
Verify things on checklist. |
…aders There were a few remaining abstract operations that operate on numeric types, that didn't have those types spelled out either via structured headers or via assertions. This converts those operations to use structured headers. That also allows ecmarkup to point out places where a ! notation was used superfluously. This revealed that the return type of RoundTemporalInstant wasn't correct: it should have been a BigInt, since it returns a number of epoch nanoseconds. Closes: #1413
|
…aders There were a few remaining abstract operations that operate on numeric types, that didn't have those types spelled out either via structured headers or via assertions. This converts those operations to use structured headers. That also allows ecmarkup to point out places where a ! notation was used superfluously. This revealed that the return type of RoundTemporalInstant wasn't correct: it should have been a BigInt, since it returns a number of epoch nanoseconds. Closes: #1413
Since the arithmetic fix in ecma262, the editorial convention is that:
For more details see 5.2.5.
This spec draft has type confusion for operating on numbers in several places. I haven't read through everything to make an exhaustive list. Some places I noticed:
The text was updated successfully, but these errors were encountered: