From 54d61b8af5bd3ab2faad389e80ddcafe42f3e0d6 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 24 Mar 2021 15:58:26 -0700 Subject: [PATCH 1/5] Editorial: Unfold SDO `CoveredParenthesizedExpression` (#2350) --- spec.html | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/spec.html b/spec.html index 6f1e83ef16..6cf24531c4 100644 --- a/spec.html +++ b/spec.html @@ -7345,7 +7345,7 @@

Function Name Inference

Static Semantics: HasName

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList - 1. Let _expr_ be CoveredParenthesizedExpression of |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Let _expr_ be the |ParenthesizedExpression| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. 1. If IsFunctionDefinition of _expr_ is *false*, return *false*. 1. Return HasName of _expr_. @@ -7398,7 +7398,7 @@

Static Semantics: HasName

Static Semantics: IsFunctionDefinition

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList - 1. Let _expr_ be CoveredParenthesizedExpression of |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Let _expr_ be the |ParenthesizedExpression| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. 1. Return IsFunctionDefinition of _expr_. @@ -7587,7 +7587,7 @@

Runtime Semantics: NamedEvaluation

With parameter _name_.

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList - 1. Let _expr_ be CoveredParenthesizedExpression of |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Let _expr_ be the |ParenthesizedExpression| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. 1. Return the result of performing NamedEvaluation for _expr_ with argument _name_. ParenthesizedExpression : `(` Expression `)` @@ -8121,7 +8121,7 @@

Static Semantics: AssignmentTargetType

CoverParenthesizedExpressionAndArrowParameterList
- 1. Let _expr_ be CoveredParenthesizedExpression of |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Let _expr_ be the |ParenthesizedExpression| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. 1. Return AssignmentTargetType of _expr_. @@ -14798,18 +14798,6 @@

Supplemental Syntax

`(` Expression[+In, ?Yield, ?Await] `)`
- -

Semantics

- - -

Static Semantics: CoveredParenthesizedExpression

- CoverParenthesizedExpressionAndArrowParameterList : `(` Expression `)` - - 1. Return the |ParenthesizedExpression| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. - -
-
-

The `this` Keyword

@@ -15498,7 +15486,7 @@

Static Semantics: Early Errors

It is a Syntax Error if |CoverParenthesizedExpressionAndArrowParameterList| is not covering a |ParenthesizedExpression|.
  • - All Early Error rules for |ParenthesizedExpression| and its derived productions also apply to CoveredParenthesizedExpression of |CoverParenthesizedExpressionAndArrowParameterList|. + All Early Error rules for |ParenthesizedExpression| and its derived productions also apply to the |ParenthesizedExpression| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|.
  • @@ -15507,7 +15495,7 @@

    Static Semantics: Early Errors

    Runtime Semantics: Evaluation

    PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList - 1. Let _expr_ be CoveredParenthesizedExpression of |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Let _expr_ be the |ParenthesizedExpression| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. 1. Return the result of evaluating _expr_. ParenthesizedExpression : `(` Expression `)` @@ -21470,7 +21458,7 @@

    Expression Rules

    PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList - 1. Let _expr_ be CoveredParenthesizedExpression of |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Let _expr_ be the |ParenthesizedExpression| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. 1. Return HasCallInTailPosition of _expr_ with argument _call_. From 7d7bde4a98c4a4b096bcd06b107dea9c5f380667 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 24 Mar 2021 15:58:32 -0700 Subject: [PATCH 2/5] Editorial: Unfold SDO `CoveredCallExpression` (#2350) --- spec.html | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/spec.html b/spec.html index 6cf24531c4..beff15f840 100644 --- a/spec.html +++ b/spec.html @@ -15636,16 +15636,6 @@

    Static Semantics: Early Errors

    - - -

    Static Semantics: CoveredCallExpression

    - - CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments - - - 1. Return the |CallMemberExpression| that is covered by |CoverCallExpressionAndAsyncArrowHead|. - -
    @@ -15776,7 +15766,7 @@

    Function Calls

    Runtime Semantics: Evaluation

    CallExpression : CoverCallExpressionAndAsyncArrowHead - 1. Let _expr_ be CoveredCallExpression of |CoverCallExpressionAndAsyncArrowHead|. + 1. Let _expr_ be the |CallMemberExpression| that is covered by |CoverCallExpressionAndAsyncArrowHead|. 1. Let _memberExpr_ be the |MemberExpression| of _expr_. 1. Let _arguments_ be the |Arguments| of _expr_. 1. Let _ref_ be the result of evaluating _memberExpr_. From 1db56bd859b6bab52e42a8126eeb6446bbfe476f Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 24 Mar 2021 15:58:34 -0700 Subject: [PATCH 3/5] Editorial: Unfold SDO `CoveredAsyncArrowHead` (#2350) --- spec.html | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/spec.html b/spec.html index beff15f840..7d2fd0afb9 100644 --- a/spec.html +++ b/spec.html @@ -5889,7 +5889,7 @@

    Static Semantics: BoundNames

    CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments
    - 1. Let _head_ be CoveredAsyncArrowHead of |CoverCallExpressionAndAsyncArrowHead|. + 1. Let _head_ be the |AsyncArrowHead| that is covered by |CoverCallExpressionAndAsyncArrowHead|. 1. Return the BoundNames of _head_. ImportDeclaration : `import` ImportClause FromClause `;` @@ -7722,7 +7722,7 @@

    Static Semantics: Contains

    1. If _symbol_ is not one of |NewTarget|, |SuperProperty|, |SuperCall|, `super`, or `this`, return *false*. - 1. Let _head_ be CoveredAsyncArrowHead of |CoverCallExpressionAndAsyncArrowHead|. + 1. Let _head_ be the |AsyncArrowHead| that is covered by |CoverCallExpressionAndAsyncArrowHead|. 1. If _head_ Contains _symbol_ is *true*, return *true*. 1. Return |AsyncConciseBody| Contains _symbol_. @@ -19550,7 +19550,7 @@

    Static Semantics: IsSimpleParameterList

    CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments - 1. Let _head_ be CoveredAsyncArrowHead of |CoverCallExpressionAndAsyncArrowHead|. + 1. Let _head_ be the |AsyncArrowHead| that is covered by |CoverCallExpressionAndAsyncArrowHead|. 1. Return IsSimpleParameterList of _head_. @@ -21034,20 +21034,10 @@

    Static Semantics: Early Errors

  • It is a Syntax Error if |CoverCallExpressionAndAsyncArrowHead| is not covering an |AsyncArrowHead|.
  • It is a Syntax Error if any element of the BoundNames of |CoverCallExpressionAndAsyncArrowHead| also occurs in the LexicallyDeclaredNames of |AsyncConciseBody|.
  • It is a Syntax Error if AsyncConciseBodyContainsUseStrict of |AsyncConciseBody| is *true* and IsSimpleParameterList of |CoverCallExpressionAndAsyncArrowHead| is *false*.
  • -
  • All Early Error rules for |AsyncArrowHead| and its derived productions apply to CoveredAsyncArrowHead of |CoverCallExpressionAndAsyncArrowHead|.
  • +
  • All Early Error rules for |AsyncArrowHead| and its derived productions apply to the |AsyncArrowHead| that is covered by |CoverCallExpressionAndAsyncArrowHead|.
  • - -

    Static Semantics: CoveredAsyncArrowHead

    - - CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments - - - 1. Return the |AsyncArrowHead| that is covered by |CoverCallExpressionAndAsyncArrowHead|. - -
    -

    Static Semantics: AsyncConciseBodyContainsUseStrict

    AsyncConciseBody : ExpressionBody @@ -21099,7 +21089,7 @@

    Runtime Semantics: InstantiateAsyncArrowFunctionExpression

    1. If _name_ is not present, set _name_ to *""*. 1. Let _scope_ be the LexicalEnvironment of the running execution context. 1. Let _sourceText_ be the source text matched by |AsyncArrowFunction|. - 1. Let _head_ be CoveredAsyncArrowHead of |CoverCallExpressionAndAsyncArrowHead|. + 1. Let _head_ be the |AsyncArrowHead| that is covered by |CoverCallExpressionAndAsyncArrowHead|. 1. Let _parameters_ be the |ArrowFormalParameters| of _head_. 1. Let _closure_ be ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, _sourceText_, _parameters_, |AsyncConciseBody|, ~lexical-this~, _scope_). 1. Perform SetFunctionName(_closure_, _name_). From b751864939e174657f5b26fa1e7baa824daeac73 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 24 Mar 2021 15:58:36 -0700 Subject: [PATCH 4/5] Editorial: Eliminate one use of SDO `CoveredFormalsList` (#2350) Here in InstantiateArrowFunctionExpression, I assert that we can replace the status quo's CoveredFormalsList of |ArrowParameters| with just |ArrowParameters| (and then eliminate the _parameters_ alias). case analysis on the 2 forms of |ArrowParameters|: case 1: When |ArrowParameters| is an instance of ArrowParameters : BindingIdentifier then CoveredFormalsList simply returns |ArrowParameters| itself, so the above replacement is obviously correct. case 2: When |ArrowParameters| is an instance of ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList then CoveredFormalsList will return an instance of ArrowFormalParameters (whose particulars are not important here), which then gets passed to OrdinaryFunctionCreate's ParameterList. But if you go to OrdinaryFunctionCreate and follow what happens to ParameterList, you find that, ultimately, it's submitted to: - ExpectedArgumentCount - BoundNames - IsSimpleParameterList - ContainsExpression - IteratorBindingInitialization And all of these have an explicit definition for: ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList of roughly the form: 1. Let _formals_ be the CoveredFormalsList of |CoverParenthesizedExpressionAndArrowParameterList|. 1. Return of _formals_. That is, with respect to the OrdinaryFunctionCreate's call-tree, if you don't call CoveredFormalsList near the root, it will be called near the leaves. So in this case too, it's okay to perform the given replacement. --- spec.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec.html b/spec.html index 7d2fd0afb9..829dcb3a92 100644 --- a/spec.html +++ b/spec.html @@ -19920,8 +19920,7 @@

    Runtime Semantics: InstantiateArrowFunctionExpression

    1. If _name_ is not present, set _name_ to *""*. 1. Let _scope_ be the LexicalEnvironment of the running execution context. 1. Let _sourceText_ be the source text matched by |ArrowFunction|. - 1. Let _parameters_ be CoveredFormalsList of |ArrowParameters|. - 1. [id="step-arrowfunction-evaluation-functioncreate"] Let _closure_ be OrdinaryFunctionCreate(%Function.prototype%, _sourceText_, _parameters_, |ConciseBody|, ~lexical-this~, _scope_). + 1. [id="step-arrowfunction-evaluation-functioncreate"] Let _closure_ be OrdinaryFunctionCreate(%Function.prototype%, _sourceText_, |ArrowParameters|, |ConciseBody|, ~lexical-this~, _scope_). 1. Perform SetFunctionName(_closure_, _name_). 1. Return _closure_. From 7cea37d366a9aa7561801e9ac027f2d047d3b27f Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 24 Mar 2021 15:58:39 -0700 Subject: [PATCH 5/5] Editorial: Unfold SDO `CoveredFormalsList` (#2350) --- spec.html | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/spec.html b/spec.html index 829dcb3a92..420278638e 100644 --- a/spec.html +++ b/spec.html @@ -5846,7 +5846,7 @@

    Static Semantics: BoundNames

    ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList - 1. Let _formals_ be CoveredFormalsList of |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Let _formals_ be the |ArrowFormalParameters| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. 1. Return the BoundNames of _formals_. GeneratorDeclaration : `function` `*` BindingIdentifier `(` FormalParameters `)` `{` GeneratorBody `}` @@ -7707,7 +7707,7 @@

    Static Semantics: Contains

    ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList - 1. Let _formals_ be CoveredFormalsList of |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Let _formals_ be the |ArrowFormalParameters| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. 1. Return _formals_ Contains _symbol_. @@ -8071,7 +8071,7 @@

    Runtime Semantics: IteratorBindingInitialization

    ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList - 1. Let _formals_ be CoveredFormalsList of |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Let _formals_ be the |ArrowFormalParameters| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. 1. Return IteratorBindingInitialization of _formals_ with arguments _iteratorRecord_ and _environment_. @@ -19481,7 +19481,7 @@

    Static Semantics: ContainsExpression

    ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList - 1. Let _formals_ be CoveredFormalsList of |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Let _formals_ be the |ArrowFormalParameters| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. 1. Return ContainsExpression of _formals_. @@ -19537,7 +19537,7 @@

    Static Semantics: IsSimpleParameterList

    ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList - 1. Let _formals_ be CoveredFormalsList of |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Let _formals_ be the |ArrowFormalParameters| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. 1. Return IsSimpleParameterList of _formals_. @@ -19614,7 +19614,7 @@

    Static Semantics: ExpectedArgumentCount

    ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList - 1. Let _formals_ be CoveredFormalsList of |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Let _formals_ be the |ArrowFormalParameters| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. 1. Return ExpectedArgumentCount of _formals_. PropertySetParameterList : FormalParameter @@ -19864,7 +19864,7 @@

    Static Semantics: Early Errors

    It is a Syntax Error if |CoverParenthesizedExpressionAndArrowParameterList| is not covering an |ArrowFormalParameters|.
  • - All early error rules for |ArrowFormalParameters| and its derived productions also apply to CoveredFormalsList of |CoverParenthesizedExpressionAndArrowParameterList|. + All early error rules for |ArrowFormalParameters| and its derived productions also apply to the |ArrowFormalParameters| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|.
  • @@ -19881,27 +19881,6 @@

    Static Semantics: ConciseBodyContainsUseStrict

    - -

    Static Semantics: CoveredFormalsList

    - ArrowParameters : BindingIdentifier - - 1. Return this |ArrowParameters|. - - - CoverParenthesizedExpressionAndArrowParameterList : - `(` Expression `)` - `(` Expression `,` `)` - `(` `)` - `(` `...` BindingIdentifier `)` - `(` `...` BindingPattern `)` - `(` Expression `,` `...` BindingIdentifier `)` - `(` Expression `,` `...` BindingPattern `)` - - - 1. Return the |ArrowFormalParameters| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. - -
    -

    Runtime Semantics: EvaluateConciseBody

    With parameters _functionObject_ and _argumentsList_ (a List).