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

Editorial: Using non-negative integral Number instead of integral Number in ToLength #3377

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

tmdghks
Copy link
Contributor

@tmdghks tmdghks commented Jul 24, 2024

In current ECMA262 specification, the abstract operation ToLength returns a integer or throw completion.
However, I think that type of the return value of ToLength can be narrowed to a non-negative integer or throw completion.

@tmdghks tmdghks changed the title Using non-negative integer instead of integer in ToLength Editorial: Using non-negative integer instead of integer in ToLength Jul 24, 2024
@jmdyck
Copy link
Collaborator

jmdyck commented Jul 24, 2024

In current ECMA262 specification, the abstract operation ToLength returns a integer or throw completion.

Not an integer, but an integral Number. That's an important distinction: in the ES spec's terminology, an integer is a "mathematical value", but a Number is a "language value". Those are completely disjoint value spaces, though they are related via conversion operations.

However, I think that type of the return value of ToLength can be narrowed to a non-negative integer or throw completion.

If you change "integer" back to "integral Number" there, I think that narrowing would be valid.

@tmdghks
Copy link
Contributor Author

tmdghks commented Jul 24, 2024

I'm sorry for incorrectly editing the specification.
I have corrected the term integer to integral Number in the specification of the ToLength abstract operation.
Thank you for your review.

@tmdghks tmdghks changed the title Editorial: Using non-negative integer instead of integer in ToLength Editorial: Using non-negative integral Number instead of integral Number in ToLength Jul 26, 2024
@michaelficarra michaelficarra added the ready to merge Editors believe this PR needs no further reviews, and is ready to land. label Oct 23, 2024
ljharb pushed a commit to tmdghks/ecma262 that referenced this pull request Oct 23, 2024
ljharb pushed a commit to tmdghks/ecma262 that referenced this pull request Oct 25, 2024
@ljharb
Copy link
Member

ljharb commented Oct 25, 2024

cc @jhnaldo for the esmeta failure; what do you recommend here? ignoring LengthOfArrayLike seems like an odd choice.

@michaelficarra
Copy link
Member

@ljharb see the linked esmeta issue I created

@jhnaldo
Copy link
Contributor

jhnaldo commented Oct 25, 2024

As I explained in es-meta/esmeta#260, the error message says that remove the line LengthOfArrayLike in the esmeta-ignore.json file because it no longer throws type errors caused by the imprecise return type of ToLength.

@ljharb
Copy link
Member

ljharb commented Oct 25, 2024

Thanks, the “add/remove” confused me :-)

ljharb pushed a commit to tmdghks/ecma262 that referenced this pull request Oct 25, 2024
@ljharb ljharb merged commit cbd470f into tc39:main Oct 25, 2024
8 checks passed
@tmdghks tmdghks deleted the fix-tolength-return-type branch October 27, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial change ready to merge Editors believe this PR needs no further reviews, and is ready to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants