Skip to content

Commit

Permalink
Change more Completion() to ? (Return)
Browse files Browse the repository at this point in the history
Specifically, change occurrences of:
```
  1. Return Completion(Evaluation of X).
```
to:
```
  1. Return ? Evaluation of X.
```
These are basically equivalent but the latter is preferred.

That is, if Evaluation returns an abrupt completion,
then the `?` will cause the algorithm to return it.
And if Evaluation returns a normal completion,
the `?` will unwrap it,
and then the Implicit Normal Completion rules will re-wrap it,
and then the `Return` will return it.
So either way, the algorithm returns the Completion that Evaluation returns.

Except: if you can prove that, for a given call site,
all invocations will return a normal completion, then it should be '!', not '?'.
However, I don't think that's true for any of the cases here.
  • Loading branch information
jmdyck committed Apr 18, 2022
1 parent 0df6091 commit b2ba000
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -18764,11 +18764,11 @@ <h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList</emu-grammar>
<emu-alg>
1. Let _expr_ be the |ParenthesizedExpression| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|.
1. Return Completion(Evaluation of _expr_).
1. Return ? Evaluation of _expr_.
</emu-alg>
<emu-grammar>ParenthesizedExpression : `(` Expression `)`</emu-grammar>
<emu-alg>
1. Return Completion(Evaluation of |Expression|). This may be of type Reference.
1. Return ? Evaluation of |Expression|. This may be of type Reference.
</emu-alg>
<emu-note>
<p>This algorithm does not apply GetValue to Evaluation of |Expression|. The principal motivation for this is so that operators such as `delete` and `typeof` may be applied to parenthesized expressions.</p>
Expand Down Expand Up @@ -21016,7 +21016,7 @@ <h1>Runtime Semantics: Evaluation</h1>
HoistableDeclaration : FunctionDeclaration
</emu-grammar>
<emu-alg>
1. Return Completion(Evaluation of |FunctionDeclaration|).
1. Return ? Evaluation of |FunctionDeclaration|.
</emu-alg>
<emu-grammar>
BreakableStatement :
Expand Down Expand Up @@ -21190,7 +21190,7 @@ <h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>BindingList : BindingList `,` LexicalBinding</emu-grammar>
<emu-alg>
1. Let _next_ be ? Evaluation of |BindingList|.
1. Return Completion(Evaluation of |LexicalBinding|).
1. Return ? Evaluation of |LexicalBinding|.
</emu-alg>
<emu-grammar>LexicalBinding : BindingIdentifier</emu-grammar>
<emu-alg>
Expand Down Expand Up @@ -21252,7 +21252,7 @@ <h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>VariableDeclarationList : VariableDeclarationList `,` VariableDeclaration</emu-grammar>
<emu-alg>
1. Let _next_ be ? Evaluation of |VariableDeclarationList|.
1. Return Completion(Evaluation of |VariableDeclaration|).
1. Return ? Evaluation of |VariableDeclaration|.
</emu-alg>
<emu-grammar>VariableDeclaration : BindingIdentifier</emu-grammar>
<emu-alg>
Expand Down Expand Up @@ -22638,15 +22638,15 @@ <h1>Runtime Semantics: Evaluation</h1>
</emu-alg>
<emu-grammar>CaseClause : `case` Expression `:` StatementList</emu-grammar>
<emu-alg>
1. Return Completion(Evaluation of |StatementList|).
1. Return ? Evaluation of |StatementList|.
</emu-alg>
<emu-grammar>DefaultClause : `default` `:`</emu-grammar>
<emu-alg>
1. Return ~empty~.
</emu-alg>
<emu-grammar>DefaultClause : `default` `:` StatementList</emu-grammar>
<emu-alg>
1. Return Completion(Evaluation of |StatementList|).
1. Return ? Evaluation of |StatementList|.
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -22744,7 +22744,7 @@ <h1>
</emu-alg>
<emu-grammar>LabelledItem : FunctionDeclaration</emu-grammar>
<emu-alg>
1. Return Completion(Evaluation of |FunctionDeclaration|).
1. Return ? Evaluation of |FunctionDeclaration|.
</emu-alg>
<emu-grammar>
Statement :
Expand All @@ -22762,7 +22762,7 @@ <h1>
DebuggerStatement
</emu-grammar>
<emu-alg>
1. Return Completion(Evaluation of |Statement|).
1. Return ? Evaluation of |Statement|.
</emu-alg>
<emu-note>
<p>The only two productions of |Statement| which have special semantics for LabelledEvaluation are |BreakableStatement| and |LabelledStatement|.</p>
Expand Down Expand Up @@ -22857,7 +22857,7 @@ <h1>
</emu-alg>
<emu-grammar>Catch : `catch` Block</emu-grammar>
<emu-alg>
1. Return Completion(Evaluation of |Block|).
1. Return ? Evaluation of |Block|.
</emu-alg>
<emu-note>
<p>No matter how control leaves the |Block| the LexicalEnvironment is always restored to its former state.</p>
Expand Down Expand Up @@ -23318,7 +23318,7 @@ <h1>
<emu-grammar>FunctionBody : FunctionStatementList</emu-grammar>
<emu-alg>
1. Perform ? FunctionDeclarationInstantiation(_functionObject_, _argumentsList_).
1. Return Completion(Evaluation of |FunctionStatementList|).
1. Return ? Evaluation of |FunctionStatementList|.
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -23501,7 +23501,7 @@ <h1>
<emu-grammar>ConciseBody : ExpressionBody</emu-grammar>
<emu-alg>
1. Perform ? FunctionDeclarationInstantiation(_functionObject_, _argumentsList_).
1. Return Completion(Evaluation of |ExpressionBody|).
1. Return ? Evaluation of |ExpressionBody|.
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -24703,7 +24703,7 @@ <h1>
<emu-grammar>ClassStaticBlockBody : ClassStaticBlockStatementList</emu-grammar>
<emu-alg>
1. Perform ? FunctionDeclarationInstantiation(_functionObject_, &laquo; &raquo;).
1. Return Completion(Evaluation of |ClassStaticBlockStatementList|).
1. Return ? Evaluation of |ClassStaticBlockStatementList|.
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -28453,15 +28453,15 @@ <h1>Runtime Semantics: Evaluation</h1>
</emu-alg>
<emu-grammar>ExportDeclaration : `export` VariableStatement</emu-grammar>
<emu-alg>
1. Return Completion(Evaluation of |VariableStatement|).
1. Return ? Evaluation of |VariableStatement|.
</emu-alg>
<emu-grammar>ExportDeclaration : `export` Declaration</emu-grammar>
<emu-alg>
1. Return Completion(Evaluation of |Declaration|).
1. Return ? Evaluation of |Declaration|.
</emu-alg>
<emu-grammar>ExportDeclaration : `export` `default` HoistableDeclaration</emu-grammar>
<emu-alg>
1. Return Completion(Evaluation of |HoistableDeclaration|).
1. Return ? Evaluation of |HoistableDeclaration|.
</emu-alg>
<emu-grammar>ExportDeclaration : `export` `default` ClassDeclaration</emu-grammar>
<emu-alg>
Expand Down

0 comments on commit b2ba000

Please sign in to comment.