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: Eliminate "unknown" as a parameter type #2745

Merged
merged 2 commits into from
Sep 23, 2022
Merged

Conversation

jmdyck
Copy link
Collaborator

@jmdyck jmdyck commented Apr 18, 2022

In the current spec, there are 250 240 AO/SDO parameters with a type of "unknown". This PR replaces almost all of those unknowns with a reasonable type.

I say "almost all" because it skips:

  • the 3 _state_ parameters handled by PR Editorial: Declare "JSON Serialization Record" #2741, and
  • the 5 _V_ and _W_ parameters of GetValue, PutValue, and InitializeReferencedBinding, because they're weird, and need some attention before they can get sensible types.

(PR #2741 and PR #2842 have both been merged, so the above exceptions have already been dealt with.)

The PR is broken into commits according to what replaces "unknown", in case that helps review. Squash before merging.

spec.html Outdated Show resolved Hide resolved
spec.html Outdated
@@ -9274,7 +9274,7 @@ <h1>Contains</h1>
<emu-clause id="sec-static-semantics-contains" oldids="sec-object-initializer-static-semantics-contains,sec-static-semantics-static-semantics-contains,sec-function-definitions-static-semantics-contains,sec-arrow-function-definitions-static-semantics-contains,sec-generator-function-definitions-static-semantics-contains,sec-async-generator-function-definitions-static-semantics-contains,sec-class-definitions-static-semantics-contains,sec-async-function-definitions-static-semantics-Contains,sec-async-arrow-function-definitions-static-semantics-Contains" type="sdo">
<h1>
Static Semantics: Contains (
_symbol_: unknown,
_symbol_: a grammar symbol,
Copy link
Member

Choose a reason for hiding this comment

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

is "a grammar symbol" something defined already?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a term that the spec uses already, but (as with most grammar-related terms) it's not defined with a <dfn>.

@jmdyck jmdyck force-pushed the unknown branch 3 times, most recently from a80692d to 76fe65d Compare April 28, 2022 13:53
@jmdyck
Copy link
Collaborator Author

jmdyck commented Aug 6, 2022

(force-pushed to resolve merge conflicts)

@michaelficarra
Copy link
Member

FYI #2842 handles the 5 _V_ and _W_ parameters of GetValue, PutValue, and InitializeReferencedBinding. So after these two PRs, all unknown parameters should be eliminated, correct?

@jmdyck
Copy link
Collaborator Author

jmdyck commented Aug 8, 2022

FYI #2842 handles the 5 _V_ and _W_ parameters of GetValue, PutValue, and InitializeReferencedBinding.

Yes, I was planning to deal with those once #2744 was merged, but bakkot beat me to it!

So after these two PRs, all unknown parameters should be eliminated, correct?

Yup. There will probably be some lurking in in-flight PRs though.

@jmdyck
Copy link
Collaborator Author

jmdyck commented Aug 16, 2022

(force-pushed to resolve merge conflicts)

spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated
@@ -39963,7 +39962,7 @@ <h1>Map ( [ _iterable_ ] )</h1>
<emu-clause id="sec-add-entries-from-iterable" type="abstract operation">
<h1>
AddEntriesFromIterable (
_target_: unknown,
_target_: an ordinary object,
Copy link
Member

Choose a reason for hiding this comment

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

is this worth calling out over just saying an Object?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hard to say if the benefit is worth the cost, because they're both fairly small (I think). I'm okay either way, whatever the editors want.

Copy link
Member

Choose a reason for hiding this comment

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

@jmdyck Decision from editor call was to not use "an ordinary object" as a parameter type unless that refinement was needed for the algorithm steps (which it isn't here).

spec.html Outdated
@@ -40907,7 +40906,7 @@ <h1>
<h1>
DetachArrayBuffer (
_arrayBuffer_: an ArrayBuffer,
optional _key_: unknown,
optional _key_: an ECMAScript language value,
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be anything.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, the spec isn't very clear on this point. I'll change it to anything.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

On second thought, DetachArrayBuffer passes _key_ to SameValue(), which only accepts language values, which is presumably why I set _key_'s type to an ECMAScript language value. I'll leave it that way unless something else changes.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should probably change the SameValue usage here to simply is. We can talk about it at the editor call.

Copy link
Member

Choose a reason for hiding this comment

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

@jmdyck Decision from editor call was to make the value as opaque as possible, so any would be better here. That will also necessitate the change from SameValue to is for comparison.

Copy link
Member

@michaelficarra michaelficarra left a comment

Choose a reason for hiding this comment

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

LGTM otherwise.

@jmdyck
Copy link
Collaborator Author

jmdyck commented Aug 30, 2022

force-pushed to rebase to main and address review comments.

@jmdyck jmdyck changed the title Editorial: Almost eliminate "unknown" as a parameter type Editorial: Eliminate "unknown" as a parameter type Aug 30, 2022
@michaelficarra michaelficarra added editor call to be discussed in the next editor call and removed editor call to be discussed in the next editor call labels Aug 30, 2022
@jmdyck
Copy link
Collaborator Author

jmdyck commented Sep 3, 2022

Force-pushed to rebase to main.
Also added commits to address decisions from editors call.

@jmdyck
Copy link
Collaborator Author

jmdyck commented Sep 14, 2022

(force-pushed to resolve merge conflict)

Copy link
Contributor

@bakkot bakkot left a comment

Choose a reason for hiding this comment

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

LGTM other than the CreateBuiltInFunction thing.

I didn't review in full detail, but the types all look reasonable.

spec.html Outdated
@@ -13865,7 +13865,7 @@ <h1>
CreateBuiltinFunction (
_behaviour_: an Abstract Closure, a set of algorithm steps, or some other definition of a function's behaviour provided in this specification,
_length_: a non-negative integer or +&infin;,
_name_: a property key,
_name_: a property key or a Private Name,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe CreateBuiltinFunction actually does take a Private Name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure about this, but consider:

class Outer {
    #Inner = class {};
}

I think the (inner) ClassExpression will be passed with a Private Name to NamedEvaluation, which then invokes ClassDefinitionEvaluation, which then invokes CreateBuiltinFunction to create the constructor method.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, yup, that's correct. The default class constructor case hadn't occurred to me.

@michaelficarra michaelficarra added the editor call to be discussed in the next editor call label Sep 20, 2022
Copy link
Contributor

@syg syg left a comment

Choose a reason for hiding this comment

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

lgtm

@michaelficarra michaelficarra added ready to merge Editors believe this PR needs no further reviews, and is ready to land. and removed editor call to be discussed in the next editor call labels Sep 21, 2022
jmdyck added a commit to jmdyck/ecma262 that referenced this pull request Sep 23, 2022
SameValue accepts only ECMAScript language values as args,
so DetachArrayBuffer's use of SameValue asserts that
detach keys are ECMAScript language values.
But detach keys should be as opaque as possible,
so replace `SameValue` with `is`.
jmdyck added a commit to jmdyck/ecma262 that referenced this pull request Sep 23, 2022
@jmdyck
Copy link
Collaborator Author

jmdyck commented Sep 23, 2022

(force-pushed to squash it down to 2 commits)

SameValue accepts only ECMAScript language values as args,
so DetachArrayBuffer's use of SameValue asserts that
detach keys are ECMAScript language values.
But detach keys should be as opaque as possible,
so replace `SameValue` with `is`.
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.

5 participants