Stage 0 Draft / August 23, 2020

Smart Pipelines

Introduction

This is the formal specification for a proposed "smart pipe operator" |> in JavaScript. It modifies the original ECMAScript specification with several new or revised clauses. The Core Proposal is at Stage 0. Additional Features are given as annexes; none of the Additional Features are at a TC39-proposal stage. See the proposal's explainer for the proposal's background, motivation, usage examples, explanation, and information on planned add-on proposals.

1 Executable Code and Execution Contexts

1.1 Lexical Environments

1.1.1 Lexical Topics

Editor's Note

This section is a wholly new sub-clause of the original Lexical Environments clause. It is forward compatible with further modifications by Additional Feature NP.

The topic binding of a Lexical Environment immutably binds the topic reference # to one value of any ECMAScript language type (called the topic value or simply the topic), within that Lexical Environment, at the time of the Lexical Environment's instantiation. The topic of a Lexical Environment conceptually serves as the value that the lexical context is "about".

A topic-binding environment is a Lexical Environment that establishes a topic binding. The topic environment of the running execution context is its Lexical Environment's nearest outer environment that is a topic-binding environment, as defined by the abstract operator GetTopicEnvironment.

Note

The only Lexical Environments that are topic-binding environments are declarative environments that are associated with PipelineTopicStep and which were created with the TopicEnvironmentInstantiation abstract operation.

There is also one syntax nonterminal that instantiates topic-binding environments with provided topic values of any ECMAScript language type. This topic-binding nonterminal is ConditionalExpression in PipelineTopicStep:ConditionalExpression , which may use the abstract operation TopicEnvironmentInstantiation. In addition, PipelineTopicStep hides its own inner topic references from Contains. Within the scope of PipelineTopicStep:ConditionalExpression , such topic references would not trigger early error rules during program compilation. Instead, they would be evaluated at runtime into the values of the newly instantiated topic-binding environments' topic bindings.

All other Lexical Environments do not establish any topic bindings; in particular, object and global environments are never topic-binding environments.

In addition, several syntax nonterminals associated with Lexical Environments are associated with early error rules that forbid their containing the topic reference #, except where the topic reference is within PipelineTopicStep:ConditionalExpression . These topic-forbidding nonterminals are:

Top-level program scopes:
ScriptBody from Script:ScriptBody .
ModuleBody from Module:ModuleBody .
Inner program scopes that establish lexical bindings:
Any FunctionStatementList from FunctionBody:FunctionStatementList , except when FunctionStatementList is the FunctionBody of a ConciseBody—that is, except when it is the body of an ArrowFunction.
Any Statement in any production of IterationStatement, such as Statement from IterationStatement:for(ForDeclarationinExpression)Statement .
Any Statement from WithStatement:with(Expression)Statement .
Any Block from Catch:catch(CatchParameter)Block .

Any use of the topic reference within these nonterminals (as detected by the static semantic rule Contains) would trigger early error rules associated with their productions: during program compilation, before runtime evaluation ever would have begun.

Also note that the other nonterminals of the productions above do not have similar topic-forbidding early error rules. For instance, the topic reference may be used as usual within ForDeclaration from ForStatement:for(ForDeclarationinExpression) .

Other syntax nonterminals, even if they similarly define inner program scopes that contain nested Statements, may contain topic references, as long as there is a topic binding in the outer scope. These other nonterminals have no early error rules that check for topic references. Topic-permitting nonterminals include:

Topic-permitting inner program scopes:
Any FunctionStatementList from FunctionBody:FunctionStatementList only in which FunctionStatementList is the FunctionBody of a ConciseBody—that is, the body of an ArrowFunction.
Any Statement in any production of IfStatement, such as .
Any CaseBlock from SwitchStatement:switch(Expression)CaseBlock .
Any Block from TryStatement:tryBlockCatch , but not Catch itself, which forbids topic references.
Any Block from Finally:finallyBlock .
Any Block from BlockStatement:Block .

These topic-permitting nonterminals’ Lexical Environments do not establish topic bindings of their own; therefore, at runtime, topic references that are contained within their scopes would be evaluated to the value of their outer environments' topic bindings. In addition, their inner topic references are visible to Contains and they are subject to the same early error rules associated with their outer scopes’ productions.

1.1.2 Environment Records

Editor's Note

This section augments the original Environment Records clause. It is forward compatible with further modifications by Additional Feature NP.

Table 1: Abstract Methods of Environment Records
Method Purpose
HasTopicBinding() Determine the status of an Environment Record's topic binding. Return true if it establishes a topic binding and false if it does not.

1.1.2.1 Declarative Environment Records

Editor's Note

Each declarative Environment Record is associated with an ECMAScript program scope containing variable, constant, let, class, module, import, and/or function declarations. A declarative Environment Record binds the set of identifiers defined by the declarations contained within its scope.

Declarative Environment Records have the additional state fields listed in Table 2.

Table 2: Additional Fields of Declarative Environment Records
Method Value Purpose
[[TopicBindingStatus]] false | true If [[TopicBindingStatus]]'s value is true, the Environment Record binds the Environment Record establishes its environment's topic binding (that is, it binds #) to values. If the value is false, the Environment Record has no topic binding. [[TopicBindingStatus]]'s default value is false. Its value may be changed from false to true but never vice versa.
[[TopicValues]] List of any | empty If the value of [[TopicBindingStatus]] is true, [[TopicValues]] is a List containing the one element which is the environment's topic value (that is, the value of # within its program scope). Otherwise, the value of [[TopicValues]] is empty.
Editor's Note

[[TopicValues]] is a List in order to be forward compatible with Additional Feature NP.

Declarative Environment Records support all of the abstract methods of Environment Records listed in Table 1. In addition, declarative Environment Records support the methods listed in Table 3.

Table 3: Additional Methods of Declarative Environment Records
Method Purpose
BindTopicValues(V) Establish the immutable topic binding of this Environment Record and set the topic binding's value. V is a List containing the one element which is the topic value and is a value of any ECMAScript language type. Afterward, the value returned by the Environment Record's HasTopicBinding method is true. This method cannot be called more than once on any single Environment Record.
Editor's Note

BindTopicValues() accepts a List argument rather than a single-value argument in order to be forward compatible with Additional Feature NP.

The behaviour of the concrete and additional specification methods for declarative Environment Records is defined by the following algorithms.

1.1.2.1.1 HasTopicBinding ( )

Editor's Note

This section is a wholly new sub-clause of the original Declarative Environment Records clause.

The concrete Environment Record method HasTopicBinding for declarative Environment Records returns the value of the record's field [[TopicBindingStatus]], which is false by default. The value may instead be true if its BindTopicValues method has been called.

  1. Let envRec be the function Environment Record for which the method was invoked.
  2. Return envRec.[[TopicBindingStatus]].

1.1.2.1.2 BindTopicValues ( V )

Editor's Note

This section is a wholly new sub-clause of the original Declarative Environment Records clause. It is forward compatible with further modifications by Additional Feature NP.

The method BindTopicValues for declarative Environment Records is guaranteed to be called only when the Environment Records do not yet have established topic bindings.

  1. Assert: V is a List.
  2. Let envRec be the declarative Environment Record for which the method was invoked.
  3. Assert: envRec.[[TopicBindingStatus]] is false.
  4. Set envRec.[[TopicValues]] to V.
  5. Set envRec.[[TopicBindingStatus]] to true.
  6. Return NormalCompletion(empty).

1.1.2.2 Object Environment Records

1.1.2.2.1 HasTopicBinding ( )

Editor's Note

This section is a wholly new sub-clause of the original Object Environment Records clause.

Regular object Environment Records never have topic bindings.

  1. Return false.

1.1.2.3 Global Environment Records

1.1.2.3.1 HasTopicBinding ( )

Editor's Note

This section is a wholly new sub-clause of the original Global Environment Records clause.

Global Environment Records never have topic bindings.

  1. Return false.

2 ECMAScript Language: Lexical Grammar

2.1 Punctuators

Editor's Note

This section augments the original Punctuators clause. It is forward compatible with further modifications by Additional Feature NP.

Punctuator::one of{()[]....;,<><=>===!====!==+-*%**++--<<>>>>>&|^!~&&||?:|>#=+=-=*=%=**=<<=>>=>>>=&=|=^==> Punctuator::one of{()[]....;,<><=>===!====!==+-*%**++--<<>>>>>&|^!~&&||?:=+=-=*=%=**=<<=>>=>>>=&=|=^==>

3 ECMAScript Language: Expressions

3.1 Primary Expression

Editor's Note

This section augments the original Primary Expression clause. It is forward compatible with further modifications by Additional Feature NP.

Syntax

PrimaryExpression[Yield, Await]:this # IdentifierReference[?Yield, ?Await] Literal ArrayLiteral[?Yield, ?Await] ObjectLiteral[?Yield, ?Await] FunctionExpression ClassExpression[?Yield, ?Await] GeneratorExpression AsyncFunctionExpression AsyncGeneratorExpression RegularExpressionLiteral TemplateLiteral[?Yield, ?Await, ~Tagged] CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]

3.1.1 The Topic Reference

Editor's Note

This section is a wholly new sub-clause to be inserted between the original this Keyword clause and the original Identifier Reference clause. It is forward compatible with further modifications by Additional Feature NP.

Note

The topic reference, which is the token #, is a nullary operator that evaluates to the value of the current Lexical Environment's topic. The topic reference acts as if it were a special variable: implicitly bound to the topic value, yet still lexically scoped. But # is not actually an IdentifierName and the topic reference is not a variable, and it cannot be bound by typical assignment; instead, it is immutably bound to a value during the instantiation of certain topic-binding environments.

The concept of lexical topic binding is further discussed in Lexical Topics and in Declarative Environment Records.

3.1.1.1 Runtime Semantics: GetTopicEnvironment

Note 1

GetTopicEnvironment finds the Environment Record that currently supplies the topic binding (the binding of #). That is, it finds the running execution topic's nearest-ancestral topic-binding environment, which is the nearest-ancestral outer environment that has a topic binding status of true. It is never called when there is no topic environment.

When the abstract operation GetTopicEnvironment is called the following steps are performed:

  1. Let lex be the running execution context's Lexical Environment.
  2. Repeat,
    1. Let envRec be lex's Environment Record.
    2. Let status be envRec.HasTopicBinding().
    3. If status is true, return envRec.
    4. Assert: lex is not a global environment.
    5. Let outer be the value of lex's outer environment reference.
    6. Set lex to outer.
  3. Return lex.
Note 2

The loop in step 2 will always terminate because the List of environments will always end before reaching the global environment. GetTopicEnvironment will never be called when there is no topic-binding environment in the List of environments.

This is because how, in general, syntax nonterminals that define top-level scopes (such as Script and Module) are syntactically forbidden to contain the topic reference #. Any use of the topic reference within those nonterminals (as detected by the static semantic rule Contains) would trigger early error rules associated with those nonterminals. It is only within nonterminals that hide the topic reference from Contains such as ConditionalExpression in PipelineTopicStep:ConditionalExpression that the topic reference is syntactically permitted.

3.1.1.2 Runtime Semantics: GetTopicValues

Note

GetTopicValues gets the values of the topic environment’s current topic binding. It is never called when there is no topic environment.

When the abstract operation GetTopicEnvironment is called the following steps are performed:

  1. Let envRec be GetTopicEnvironment().
  2. Assert: envRec is a declarative Environment Record.
  3. Assert: envRec.HasTopicBinding() is true.
  4. Let topicValues be envRec.[[TopicValues]].
  5. Assert: topicValues has at least one element.
  6. Return topicValues.

3.1.1.3 Runtime Semantics: Evaluation

PrimaryExpression:#
  1. Let topicValues be GetTopicValues().
  2. Return topicValues_[0].

3.1.2 Function Calls

3.1.2.1 Runtime Semantics: EvaluateCall(func, ref, arguments, tailPosition )

Editor's Note

This section is an augmentation of the original EvaluateCall clause such that its arguments parameter may be a List, rather than a Parse Node that will undergo ArgumentListEvaluation into a List.

The abstract operation EvaluateCall takes as arguments a value func, a value ref, a Parse Node or List arguments, and a Boolean argument tailPosition. It performs the following steps:

  1. Assert: arguments is either a Parse Node or a List.
  2. If Type(ref) is Reference, then
    1. If IsPropertyReference(ref) is true, then
      1. Let thisValue be GetThisValue(ref).
    2. Else the base of ref is an Environment Record,
      1. Let refEnv be GetBase(ref).
      2. Let thisValue be refEnv.WithBaseObject().
  3. Else Type(ref) is not Reference,
    1. Let thisValue be undefined.
  4. If arguments is a List, let argList be arguments.
  5. Else lLet argList be ArgumentListEvaluation of arguments.
  6. ReturnIfAbrupt(argList).
  7. If Type(func) is not Object, throw a TypeError exception.
  8. If IsCallable(func) is false, throw a TypeError exception.
  9. If tailPosition is true, perform PrepareForTailCall().
  10. Let result be Call(func, thisValue, argList).
  11. Assert: If tailPosition is true, the above call will not return here, but instead evaluation will continue as if the following return has already occurred.
  12. Assert: If result is not an abrupt completion, then Type(result) is an ECMAScript language type.
  13. Return result.

3.2 Pipe Operator

Editor's Note

This section is a wholly new sub-clause to be inserted between the original Conditional Operator (? :) clause and the original Assignment Operators clause. It is forward compatible with further modifications by Additional Feature BP and further modifications by Additional Feature NP.

Syntax

PipeExpression[In, Yield, Await]:ConditionalExpression[?In, ?Yield, ?Await] ConditionalExpression[?In, ?Yield, ?Await]|>Pipeline[?In, ?Yield, ?Await] Pipeline[In, Yield, Await]:CoverPipelineBareStepAndTopicStep[?In, ?Yield, ?Await] CoverPipelineBareStepAndTopicStep[?In, ?Yield, ?Await]|>Pipeline[?In, ?Yield, ?Await] CoverPipelineBareStepAndTopicStep[In, Yield, Await]:ConditionalExpression[?In, ?Yield, ?Await]

Supplemental Syntax

When processing an instance of the production CoverPipelineBareStepAndTopicStep:ConditionalExpression , the interpretation of ConditionalExpression is refined using the following grammar:

PipelineBareStep:SimpleReference SimpleReference:IdentifierReference SimpleReference.IdentifierName PipelineTopicStep[In, Yield, Await]:[lookahead ∉ { { }]ConditionalExpression[?In, ?Yield, ?Await]

3.2.1 Static Semantics: Early Errors

Editor's Note

This section is a wholly new sub-clause. It is forward compatible with further modifications by Additional Feature NP.

PipeExpression:ConditionalExpression|>Pipeline PipelineTopicStep:ConditionalExpression
  1. It is a Syntax Error if ConditionalExpression is covering Arguments.
Editor's Note

These early errors prohibit any pipeline input expressions or pipeline step expressions from covering comma-separated argument lists. This in turn ensures forward compatibility with further modifications by Additional Feature NP.

PipelineTopicStep:ConditionalExpression
  1. It is a Syntax Error if ConditionalExpression Contains # is false.
  2. It is a Syntax Error if ConditionalExpression is covering a YieldExpression.
  3. It is a Syntax Error if ConditionalExpression is covering a PipelineTopicListHead.
Editor's Note

This third early error prohibits a topic-style pipeline step from covering a comma-separated expression. This in turn ensures forward compatibility with further modifications by Additional Feature NP.

3.2.2 Static Semantics: Contains

With parameter symbol.

Editor's Note

This section is a wholly new sub-clause. It is forward compatible with further modifications by Additional Feature NP.

PipelineTopicStep:ConditionalExpression
  1. If symbol is #, return false.
  2. For each child node child of this Parse Node, do
    1. If child is an instance of symbol, return true.
    2. If child is an instance of a nonterminal, then
      1. Let contained be the result of child Contains symbol.
      2. If contained is true, return true.
  3. Return false.

3.2.3 Static Semantics: CoveredPipelineStep

Editor's Note

This section is a wholly new sub-clause.

CoverPipelineBareStepAndTopicStep:ConditionalExpression
  1. If ConditionalExpression is covering a PipelineBareStep, return the PipelineBareStep that is covered by ConditionalExpression.
  2. Else, return the PipelineTopicStep that is covered by ConditionalExpression.

3.2.4 Static Semantics: ExpectedArgumentCount

Editor's Note

This section is not strictly required for the core proposal, but it would be commonly used by both Additional Feature PF and Additional Feature NP.

PipelineBareStep:SimpleReference
  1. Return 0.
PipelineTopicStep:ConditionalExpression
  1. Return 1.
Pipeline:CoverPipelineBareStepAndTopicStep|>Pipeline
  1. Let pipelineStep be CoveredPipelineStep of CoverPipelineBareStepAndTopicStep.
  2. Return ExpectedArgumentCount of pipelineStep.

3.2.5 Runtime Semantics: TopicEnvironmentInstantiation

Editor's Note

This section is a wholly new sub-clause. It is forward compatible with further modifications by Additional Feature NP.

Note

This abstract operation constructs, instantiates, then returns a new declarative Lexical Environment for a topic-style pipeline step. It creates an immutable topic binding in that declarative environment using the given topicValues.

TopicPipelineInstantiation is performed as follows using arguments env and topicValues.

  1. Assert: topicValues is a List.
  2. Let envRec be env's Environment Record.
  3. Assert: envRec is a declarative Environment Record.
  4. Assert: envRec.HasTopicBinding() is false.
  5. Assert: envRec.[[TopicValues]] is empty.
  6. Perform ! envRec.BindTopicValues(topicValues).

3.2.6 Runtime Semantics: PipelineEvaluation

With parameter inputValues.

PipelineBareFunction:SimpleReference
  1. Let memberExpr be the MemberExpression that is covered by SimpleReference.
  2. Let funcRef be the result of evaluating memberExpr.
  3. Let funcValue be ? GetValue(ref).
  4. Let thisCall be this PipelineBareFunction.
  5. Let tailCall be IsInTailPosition(thisCall).
  6. Let callRef be ? EvaluateCall(funcValue, ref, inputValues, tailCall).
  7. Let callValue be ? GetValue(callRef).
  8. Return a List containing the one element which is callValue.
PipelineTopicStep:ConditionalExpression
  1. Let oldEnv be the running execution context's Lexical Environment.
  2. Let pipelineStepEnv be New Declarative Environment(oldEnv).
  3. Perform TopicEnvironmentInstantiation(inputValues, pipelineStepEnv).
  4. Set the running execution context's Lexical Environment to pipelineStepEnv.
  5. Let pipelineValue be the result of evaluating ConditionalExpression.
  6. Set the running execution context's Lexical Environment to oldEnv.
  7. Return a List containing the one element which is pipelineValue.
Pipeline:CoverPipelineBareStepAndTopicStep|>Pipeline
  1. Let pipelineStep be ? CoveredPipelineStep of CoverPipelineBareStepAndTopicStep.
  2. Let stepOutputValues be ? PipelineEvaluation of pipelineStep with argument inputValues.
  3. Let pipelineRemainderOutputRef be ? PipelineEvaluation of Pipeline with argument stepOutputValues.
  4. Return ? GetValue(pipelineRemainderOutputRef).

3.2.7 Runtime Semantics: Evaluation

PipeExpression:ConditionalExpression|>Pipeline
  1. Let inputRef be the result of evaluating ConditionalExpression.
  2. Let inputValues be a List containing the one element which is the result of ? GetValue(inputRef).
  3. Let pipelineOutputValues be ? PipelineEvaluation of Pipeline with argument inputValues.
  4. Assert: pipelineOutputValues is a List containing one element.
  5. Return pipelineOutputValues[0].

3.3 Assignment Operators

Editor's Note

This section augments the original Assignment Operators clause. It is forward compatible with further modifications by Additional Feature PF.

Syntax

AssignmentExpression[In, Yield, Await]:ConditionalExpression[?In, ?Yield, ?Await] PipeExpression[?In, ?Yield, ?Await] [+Yield]YieldExpression[?In, ?Await] ArrowFunction[?In, ?Yield, ?Await] AsyncArrowFunction[?In, ?Yield, ?Await] LeftHandSideExpression[?Yield, ?Await]=AssignmentExpression[?In, ?Yield, ?Await] LeftHandSideExpression[?Yield, ?Await]AssignmentOperatorAssignmentExpression[?In, ?Yield, ?Await]

4 ECMAScript Language: Statements and Declarations

4.1 Iteration Statements

Editor's Note

This section augments the original Iteration Statements clause. It is forward compatible with further modifications by Additional Feature NP and further modifications by Additional Feature TS.

4.1.1 Static Semantics: Early Errors

IterationStatement:doStatementwhile(Expression); while(Expression)Statement for(Expressionopt;Expressionopt;Expressionopt)Statement for(varVariableDeclarationList;Expressionopt;Expressionopt)Statement for(LexicalDeclarationExpressionopt;Expressionopt)Statement for(LeftHandSideExpressioninExpression)Statement for(varForBindinginExpression)Statement for(ForDeclarationinExpression)Statement for(LeftHandSideExpressionofAssignmentExpression)Statement for(varForBindingofAssignmentExpression)Statement for(ForDeclarationofAssignmentExpression)Statement forawait(LeftHandSideExpressionofAssignmentExpression)Statement forawait(varForBindingofAssignmentExpression)Statement forawait(ForDeclarationofAssignmentExpression)Statement
  • It is a Syntax Error if Statement Contains # is true.
Note

Syntax nonterminals that establish new lexical bindings within new inner program scopes, including iteration statements, may not contain a topic reference #. However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as ConditionalExpression in PipelineTopicStep:ConditionalExpression , which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early error above.

4.2 The with statement

4.2.1 Static Semantics: Early Errors

Editor's Note

This section augments the original with Statement, Static Semantics: Early Errors clause. It is forward compatible with further modifications by Additional Feature NP. It is not planned to be removed by other additional syntax.

WithStatement:with(Expression)Statement
  • It is a Syntax Error if Statement Contains # is true.
Note

Syntax nonterminals that establish new lexical bindings within new inner program scopes, including WithStatement, may not contain a topic reference #. However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as ConditionalExpression in PipelineTopicStep:ConditionalExpression , which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early error above.

4.3 The try statement

4.3.1 Static Semantics: Early Errors

Editor's Note

This section augments the original try Statement, Static Semantics: Early Errors clause. It is forward compatible with further modifications by Additional Feature NP and further modifications by Additional Feature TS. [TODO: Add link to Additional Feature TS once it’s written.]

Catch:catch(CatchParameter)Block
  • It is a Syntax Error if Block Contains # is true.
Note

Syntax nonterminals that establish new lexical bindings within new inner program scopes, including Catch, may not contain a topic reference #. However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as ConditionalExpression in PipelineTopicStep:ConditionalExpression , which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early errors above.

Furthermore, the try and finally blocks themselves (Block and Finally in TryStatement) may contain topic references, assuming that the TryStatement is contained within a parse that is also allowed to contain the topic reference. During runtime, such topic references would refer to the outer environment's topic binding. Along with arrow functions (that is, FunctionBody in ConciseBody), this behaviour is unlike that of any other syntax nonterminal containing Statement.

5 ECMAScript Language: Functions and Classes

5.1 Function Definitions

5.1.1 Static Semantics: Early Errors

Editor's Note FunctionBody:FunctionStatementList Note

Arrow functions' ConciseBody may contain the topic reference #, as long as ConciseBody is within a parse that is also allowed to contain the topic reference. During runtime, such topic references would refer to the outer environment's topic binding. This is not true for the definitions of other types of functions, which may not contain any topic reference.

Along with Block in TryStatement, this behaviour is unlike that of any other syntax nonterminal containing Statement. Syntax nonterminals that establish new lexical bindings within new inner program scopes, including FunctionBody, may not contain a topic reference #.

5.2 Arrow Function Definitions

5.2.1 Static Semantics: Contains

With parameter symbol.

Editor's Note ArrowFunction:ArrowParameters=>ConciseBody
  1. If symbol is not one of NewTarget, SuperProperty, SuperCall, super or this super, this, or #, return false.
  2. If ArrowParameters Contains symbol is true, return true.
  3. Return ConciseBody Contains symbol.
Note
Normally, Contains does not look inside most function forms. However, Contains is used to detect new.target, this, and superthis, super, and # usage within an ArrowFunction.

6 ECMAScript Language: Scripts and Modules

6.1 Scripts

6.1.1 Static Semantics: Early Errors

Editor's Note

This section augments the original Scripts, Static Semantics: Early Errors clause. It is forward compatible with further modifications by Additional Feature NP. It is not planned to be removed by other additional syntax.

ScriptBody:StatementList Note

In general, a top-level program scope, including Script, may not contain a topic reference #. However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as ConditionalExpression in PipelineTopicStep:ConditionalExpression , which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early error above.

6.2 Modules

6.2.1 Static Semantics: Early Errors

Editor's Note

This section augments the original Modules, Static Semantics: Early Errors clause. It is forward compatible with further modifications by Additional Feature NP. It is not planned to be removed by other additional syntax.

ModuleItem:StatementListItem Note

In general, a top-level program scope, including Module, may not contain a topic reference #. However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as ConditionalExpression in PipelineTopicStep:ConditionalExpression , which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early error above.

A Additional Feature BC: Bare Constructor Calls

Not at Stage 0.

This annex specifies additional ECMAScript language syntax and semantics for bare constructor calls. It augments the core proposal by introducing an additional bare-style pipeline form, in which a SimpleReference is prepended with an new.

See the explainer document, § Motivation, Additional Feature BC for information on this feature's motivation.

A.1 ECMAScript Language: Expressions

A.1.1 Primary Expression

A.1.1.1 The new Operator

A.1.1.1.1 Runtime Semantics: Evaluation

A.1.1.1.1.1 Runtime Semantics: EvaluateNew ( constructExpr, arguments )

Editor's Note

This section is an augmentation of the original EvaluateNew clause such that its arguments parameter may be a List, rather than a Parse Node that will undergo ArgumentListEvaluation into a List.

The abstract operation EvaluateNew with arguments constructExpr, and arguments performs the following steps:

  1. Assert: constructExpr is either a NewExpression or a MemberExpression.
  2. Assert: arguments is either empty, a List, or an Arguments.
  3. Let ref be the result of evaluating constructExpr.
  4. Let constructor be ? GetValue(ref).
  5. If arguments is empty, let argList be a new empty List.
  6. Else if arguments is a List, let argList be arguments.
  7. Else,
    1. Let argList be ArgumentListEvaluation of arguments.
    2. ReturnIfAbrupt(argList).
  8. If IsConstructor(constructor) is false, throw a TypeError exception.
  9. Return ? Construct(constructor, argList).

A.1.2 Pipe Operator

Editor's Note

This section augments the new clause in the core proposal. It is mutually compatible with further modifications by Additional Feature NP.

Supplemental Syntax

PipelineBareStep:SimpleReference newSimpleReference

A.1.2.1 Static Semantics: ExpectedArgumentCount

Editor's Note

This section augments the new clause in the core proposal. It is mutually compatible with further modifications by other additional features.

PipelineBareStep:SimpleReference newSimpleReference
  1. Return 0.

A.1.2.2 Runtime Semantics: PipelineEvaluation

With parameter inputValues.

Editor's Note

This section augments the new clause in the core proposal.

PipelineBareStep:newSimpleReference
  1. Let constructExpr be the MemberExpression that is covered by SimpleReference.
  2. Let newRef be ? EvaluateNew(NewExpression, inputValues).
  3. Let newValue be ? GetValue(newRef).
  4. Return a List containing the one element which is newValue.

B Additional Feature BA: Bare Awaited Calls

Not at Stage 0.

This annex specifies additional ECMAScript language syntax and semantics for bare awaited function calls. It augments the core proposal by introducing an additional bare-style pipeline form, in which a SimpleReference is prepended with an await.

See the explainer document, § Motivation, Additional Feature BA for information on this feature's motivation.

B.1 ECMAScript Language: Expressions

B.1.1 Pipe Operator

Editor's Note

This section augments the new clause in the core proposal. It is mutually compatible with further modifications by Additional Feature NP.

Supplemental Syntax

PipelineBareAwaitedFunction[Await]:[+Await]awaitSimpleReference

B.1.1.1 Static Semantics: ExpectedArgumentCount

Editor's Note

This section augments the new clause in the core proposal. It is mutually compatible with further modifications by other additional features.

PipelineBareStep:SimpleReference awaitSimpleReference
  1. Return 0.

B.1.1.2 Runtime Semantics: PipelineEvaluation

With parameter inputValues.

Editor's Note

This section augments the new clause in the core proposal.

PipelineBareAwaitedFunction:awaitSimpleReference

This algorithm is an altered version of the algorithm of Function Calls, Runtime Semantics: Evaluation, modified as follows:

  1. Let memberExpr be the MemberExpression that is covered by SimpleReference.
  2. Let ref be the result of evaluating memberExpr.
  3. Let func be ? GetValue(ref).
  4. Let thisCall be this PipelineBareFunction.
  5. Let tailCall be IsInTailPosition(thisCall).
  6. Let callRef be ? EvaluateCall(func, ref, inputValues, tailCall).
  7. Let callValue be ? GetValue(exprRef).
  8. Let awaitRef be ? Await(callValue).
  9. Let awaitValue be ? GetValue(awaitRef).
  10. Return a List containing the one element which is awaitValue.

C Additional Feature BP: Block Pipelines

Not at Stage 0.

This annex specifies additional ECMAScript language syntax and semantics for pipeline functions. It augments the core proposal by introducing an additional topic-style pipeline form: a Block.

See the explainer document, § Motivation, Additional Feature BP for information on this feature's motivation.

C.1 ECMAScript Language: Expressions

C.1.1 Pipe Operator

Editor's Note

This section augments the new clause in the core proposal. It is mutually compatible with further modifications by other additional features.

Supplemental Syntax

PipelineTopicStep[In, Yield, Await]:[lookahead ∉ { { }]ConditionalExpression[?In, ?Yield, ?Await] Block[?In, ?Yield, ?Await]

C.1.1.1 Static Semantics: Early Errors

Editor's Note

This section augments the new clause in the core proposal.

PipelineTopicStep:Block
  1. It is a Syntax Error if StatementList Contains # is false.

C.1.1.2 Static Semantics: Contains

With parameter symbol.

Editor's Note

This section augments the new clause in the core proposal.

PipelineTopicStep:ConditionalExpression Block
  1. If symbol is #, return false.
  2. For each child node child of this Parse Node, do
    1. If child is an instance of symbol, return true.
    2. If child is an instance of a nonterminal, then
      1. Let contained be the result of child Contains symbol.
      2. If contained is true, return true.
  3. Return false.

C.1.1.3 Runtime Semantics: PipelineEvaluation

With parameter inputValues.

PipelineTopicStep:Block
  1. Let oldEnv be the running execution context's Lexical Environment.
  2. Let pipelineStepEnv be New Declarative Environment(oldEnv).
  3. Perform TopicEnvironmentInstantiation(inputValues, pipelineStepEnv).
  4. Set the running execution context's Lexical Environment to pipelineStepEnv.
  5. Let pipelineValue be the result of evaluating Body.
  6. Set the running execution context's Lexical Environment to oldEnv.
  7. Return a List containing the one element which is pipelineValue.

D Additional Feature PF: Pipeline Functions

Not at Stage 0.

This annex specifies additional ECMAScript language syntax and semantics for pipeline functions. It augments the core proposal by introducing an additional pipeline-function operator +>. This new unary operator creates arrow functions with an implicit parameter inputted into a pipeline. The operator brings much power: it enables terse method extraction, terse partial application of functions/expressions (into unary functions), and terse composition of functions/expressions.

[TODO: This annex is unfinished. Async pipeline functions are yet to be added.]

See the explainer document, § Motivation, Additional Feature PF for information on this feature's motivation.

Table 4: Examples of Pipeline Functions
+> console.log;
(...$) => console.log(...$)
console.log.bind(console);
+> f(#, 5);
$ => f($, 5);
+> # + 1;
$ => $ + 1;
+> f |> g;
(...$) => g(f(...$));
+> f |> o.m;
(...$) => o.m(f(...$));
+> f |> # + 1 |> o.m;
(...$) => o.m(f(...$) + 1);

This annex uses a new token +>, but this token is merely an illustrative placeholder to avoid premature bikeshedding discussion. The actual operator ideally would communicate its status as a combination of => and |>. Example replacements of +> include -> Pipeline (which both resembles the |> operator with the | rotated sideways and resembles the => operator but with a narrower arrow body) and =| Pipeline (which is a blending of => and |> with the > removed).

D.1 ECMAScript Language: Expressions

D.1.1 Assignment Operators

Editor's Note

Syntax

AssignmentExpression[In, Yield, Await]:PipeExpression[?In, ?Yield, ?Await] PipelineFunction[?In, ?Yield, ?Await] [+Yield]YieldExpression[?In, ?Await] ArrowFunction[?In, ?Yield, ?Await] AsyncArrowFunction[?In, ?Yield, ?Await] LeftHandSideExpression[?Yield, ?Await]=AssignmentExpression[?In, ?Yield, ?Await] LeftHandSideExpression[?Yield, ?Await]AssignmentOperatorAssignmentExpression[?In, ?Yield, ?Await]

D.2 ECMAScript Language: Functions and Classes

D.2.1 Pipeline Function Definitions

Editor's Note

This section would be a wholly new sub-clause to the ECMAScript Language: Functions and Classes clause.

Syntax

PipelineFunction[In, Yield, Await]:+>Pipeline[?In, ?Yield, ?Await]

D.2.1.1 Static Semantics: BoundNames

PipelineFunction[In, Yield, Await]:+>Pipeline[?In, ?Yield, ?Await]
  1. Return a new empty List.

D.2.1.2 Static Semantics: Contains

With parameter symbol.

PipelineFunction[In, Yield, Await]:+>Pipeline[?In, ?Yield, ?Await]
  1. If symbol is not one of NewTarget, SuperProperty, SuperCall, super or this super, this, or #, return false.
  2. Return Pipeline Contains symbol.
Note
Normally, Contains does not look inside most function forms. However, Contains is used to detect new.target, this, super, and # usage within a PipelineFunction.

D.2.1.3 Static Semantics: ContainsExpression

PipelineFunction[In, Yield, Await]:+>Pipeline[?In, ?Yield, ?Await]
  1. Return false.

D.2.1.4 Static Semantics: ContainsUseStrict

PipelineFunction[In, Yield, Await]:+>Pipeline[?In, ?Yield, ?Await]
  1. Return false.

D.2.1.5 Static Semantics: ExpectedArgumentCount

Note

Because the formal parameter lists of pipeline functions are their pipelines themselves, the ExpectedArgumentCount of pipeline functions is implicitly specified by the ExpectedArgumentCount of the pipelines.

D.2.1.6 Static Semantics: HasName

PipelineFunction:+>Pipeline
  1. Return false.

D.2.1.7 Static Semantics: IsSimpleParameterList

PipelineFunction:+>Pipeline
  1. Return true.

D.2.1.8 Runtime Semantics: IteratorBindingInitialization

With parameters iteratorRecord and environment.

PipelineFunction[In, Yield, Await]:+>Pipeline[?In, ?Yield, ?Await]
  1. Return NormalCompletion(empty).
Note

This syntax-directed operation is defined for array destructuring, function parameters, arrow-function parameters, and async-arrow-function parameters, and it is used by FunctionDeclarationInstantiation to bind function parameters to function arguments during a function call. iteratorRecord is an Iterator object of the argument List created with CreateListIteratorRecord. environment is the Environment Record within which the parameter bindings are to be established.

However, pipeline functions do not use IteratorBindingInitialization to create parameter bindings; instead, they pass their arguments directly into PipelineEvaluation, as specified in their algorithm for EvaluateBody.

D.2.1.9 Static Semantics: LexicallyDeclaredNames

PipelineFunction[In, Yield, Await]:+>Pipeline[?In, ?Yield, ?Await]
  1. Return a new empty List.

D.2.1.10 Static Semantics: LexicallyScopedDeclarations

PipelineFunction[In, Yield, Await]:+>Pipeline[?In, ?Yield, ?Await]
  1. Return a new empty List.

D.2.1.11 Static Semantics: VarDeclaredNames

PipelineFunction[In, Yield, Await]:+>Pipeline[?In, ?Yield, ?Await]
  1. Return a new empty List.

D.2.1.12 Static Semantics: VarScopedDeclarations

PipelineFunction[In, Yield, Await]:+>Pipeline[?In, ?Yield, ?Await]
  1. Return a new empty List.

D.2.1.13 Runtime Semantics: EvaluateBody

With parameters functionObject and List argumentsList.

PipelineFunction[In, Yield, Await]:+>Pipeline[?In, ?Yield, ?Await]
  1. Perform ? FunctionDeclarationInstantiation(functionObject, argumentsList).
  2. Let exprRef be ? PipelineEvaluation of Pipeline with argument argumentsList.
  3. Let exprValue be ? GetValue(exprRef).
  4. Return Completion{[[Type]]: return, [[Value]]: exprValue, [[Target]]: empty}.

D.2.1.14 Runtime Semantics: Evaluation

PipelineFunction[In, Yield, Await]:+>Pipeline[?In, ?Yield, ?Await]
  1. If the PipelineFunction is declared in strict mode code, let strict be true. Otherwise let strict be false.
  2. Let scope be the LexicalEnvironment of the running execution context.
  3. Let closure be FunctionCreate(Arrow, Pipeline, Pipeline, scope, strict).
  4. Return closure.

E Additional Feature NP: N-ary Pipelines

Not at Stage 0.

This annex specifies additional ECMAScript language syntax and semantics for n-ary smart pipelines and multiple lexical topics. It augments the core proposal by introducing n-ary pipeline forms inputList |> … and … |> stepList |> …, an additional secondary topic reference ##, a tertiary topic reference ###, a RestTopicReference ..., and an argument-List syntax to bind the new references [TODO: xref]. When combined with the additional feature PF, the resulting additional feature PF+NP enables partial application of functions/expressions into n-ary functions. [TODO: xref with PF+NP]

See the explainer document, § Motivation, Additional Feature NP for information on this feature's motivation.

Table 5: Examples of Multiple Lexical Topics
a |> f;
f(a);
(a) |> f;
f(a);
(a, b) |> f;
f(a, b);
(...a) |> f;
f(...a);
...a |> f;
...a |> f(...);
f(...a);
...a |> f(x, ...);
f(x, ...a);
() |> f;
() |> f(...);
f();
(a, b) |> # + ##;
a + b;
...a |> # + ##;
a |> ... |> # + ##;
{ const [$, $$] = [...a]; $ + $$; }
() |> # + ##;
Syntax Error: Pipeline head inputs 0 topic values () into a following step that expects 2 topic values.
(a, b) |> f(#, 0, ##);
f(a, 0, b);
(a, b) |> f(0, ##);
f(0, b);
(a, b, c, d) |> f(#, 0, ...);
f(a, 0, b, c, d);
(a, b, c, d) |> f(##, 0, ...);
f(b, 0, c, d);
(a, b, c, d) |> f(##, 0, [...]);
f(b, 0, [c, d]);
(a, ...[b, c, d]) |> f(##, 0, [...]);
f(b, 0, [c, d]);
(a, b) |> (# * b, ##) |> f;
g(a * b, f(b));
(a, b) |> (# * b, #) |> f;
Syntax Error: Pipeline head inputs 2 topic values (a, b) into following step that expects 1 topic value.
(a, b) |> (# * b, f) |> f;
Syntax Error: Topic-style pipeline step f in (# * b, f) binds topic but contains no topic reference.
(a, b) |> #;
Syntax Error: Pipeline head inputs 2 topic values (a, b) into following step that expects 1 topic value.
a |> # + ##;
Syntax Error: Pipeline head inputs 1 topic values a into following step that expects 2 topic values.
() |> # * 5;
Syntax Error: Pipeline head inputs 0 topic values () into following step that expects 1 topic value.
(a, b) |> f(#, 0);
Syntax Error: Pipeline head inputs 2 topic values (a, b) into following step that expects 1 topic value.
(a, b) |> (#, ##);
Syntax Error: Pipeline terminates with a 2-ary pipeline step but must terminate with a unary pipeline step.

E.1 Executable Code and Execution Contexts

E.1.1 Lexical Environments

E.1.1.1 Lexical Topics

Editor's Note

This section further augments the corresponding new clause in the core proposal.

The topic binding of a Lexical Environment immutably binds the topic reference # to one value of any ECMAScript language type (called the topic value or simply the topic), within that Lexical Environment, at the time of the Lexical Environment's instantiationtopic references #, ##, ###, and ..., each to a respective topic value of any ECMAScript language type. The token # is termed the primary topic reference, ## is termed the secondary topic reference, and ### is termed the tertiary topic reference; together, they form the TopicExpressions. In addition, ... alone forms the RestTopicReference, which represents a List of topic values of any ECMAScript language type. A single topic binding will bind all of a Lexical Environment's topic references at once at the time of the Lexical Environment's instantiation, after which the binding cannot change. The topics of a Lexical Environment conceptually serves as the values that the lexical context is "about".

A topic-binding environment is a Lexical Environment that establishes a topic binding. The topic environment of the running execution context is its Lexical Environment's nearest outer environment that is a topic-binding environment, as defined by the abstract operator GetTopicEnvironment.

Note

In addition, several syntax productions associated with Lexical Environments are associated with early error rules that forbid their containing the topic references #, ##, ###, or ..., except where that topic reference iss are within a PipelineTopicStep. These topic-forbidding productions are:

Top-level program scopes:
ScriptBody from Script:ScriptBody .
ModuleBody from Module:ModuleBody .
Inner program scopes that establish lexical bindings:
Any FunctionStatementList from FunctionBody:FunctionStatementList , except when FunctionStatementList is the FunctionBody of a ConciseBody—that is, except when it is the body of an ArrowFunction.
Any Statement in any production of IterationStatement, such as Statement from IterationStatement:for(ForDeclarationinExpression)Statement .
Any Statement from WithStatement:with(Expression)Statement .
Any Block from Catch:catch(CatchParameter)Block .

E.1.2 Environment Records

Editor's Note

This section augments the new clause in the core proposal.

Table 6: Abstract Methods of Environment Records
Method Purpose
HasTopicBinding() Determine the status of an Environment Record's topic binding (that is, the bindings of #, ##, ###, and ...). Return true if it establishes a topic binding and false if it does not.

E.1.2.1 Declarative Environment Records

Editor's Note
Table 7: Additional Fields of Declarative Environment Records
Method Value Purpose
[[TopicBindingStatus]] false | true If [[TopicBindingStatus]]'s value is true, the Environment Record establishes its environment's topic binding (that is, it binds #, ##, ###, and ...) to values. If the value is false, the Environment Record has no topic binding. [[TopicBindingStatus]]'s default value is false. Its value may be changed from false to true but never vice versa.
[[TopicValues]] Any | empty If the value of [[TopicBindingStatus]] is true, [[TopicValues]] is a List containing is the values of the Environment Record's topic binding (that is, the values of #, ##, and ### within its program scope). Otherwise, the value of [[TopicValues]] is empty.
[[RestTopicStartIndex]] Integer index | empty If the value of [[TopicBindingStatus]] is true, [[RestTopicStartIndex]] is the first index in [[TopicValues]] of its Lexical Environment's rest topic reference ...; if so, this index must be an integer inclusively between 0 and the number of elements of [[TopicValues]]. If the value of [[TopicBindingStatus]] is false, the value of [[RestTopicStartIndex]] is empty.

Declarative Environment Records support all of the abstract methods of Environment Records listed in Table 1. In addition, declarative Environment Records support the methods listed in Table 3.

Table 8: Additional Methods of Declarative Environment Records
Method Purpose
BindTopicValues(V, VRestStartIndex) Establish the immutable topic binding of this Environment Record and set the topic bindings''s values. V is the value for the binding and is a value of any ECMAScript language type.V is a List with elements of any ECMAScript language type. VRestStartIndex is either empty or an Array whose elements are of any ECMAScript language type. Afterward, the value returned by the Environment Record's HasTopicBinding method is true. This method cannot be called more than once on any single Environment Record.

The behaviour of the concrete and additional specification methods for declarative Environment Records is defined by the following algorithms.

E.1.2.1.1 BindTopicValues ( V, VRestStartIndex )

Editor's Note

This section augments the new clause in the core proposal.

The method BindTopicValues for declarative Environment Records is guaranteed to be called only when the Environment Records do not yet have established topic bindings.

  1. Assert: V is a List.
  2. Assert: VRest is either empty or an Array.
  3. Let envRec be the declarative Environment Record for which the method was invoked.
  4. Assert: envRec.[[TopicBindingStatus]] is false.
  5. Set envRec.[[TopicValues]] to V.
  6. Set envRec.[[RestTopicStartIndex]] to VRestStartIndex.
  7. Set envRec.[[TopicBindingStatus]] to true.
  8. Return NormalCompletion(empty).

E.2 ECMAScript Language: Lexical Grammar

E.2.1 Punctuators

Editor's Note Punctuator::one of{()[]....;,<><=>===!====!==+-*%**++--<<>>>>>&|^!~&&||?:|>######=+=-=*=%=**=<<=>>=>>>=&=|=^==> Punctuator::one of{()[]....;,<><=>===!====!==+-*%**++--<<>>>>>&|^!~&&||?:|>#=+=-=*=%=**=<<=>>=>>>=&=|=^==>

E.3 ECMAScript Language: Expressions

E.3.1 Primary Expression

Editor's Note

Syntax

PrimaryExpression[Yield, Await]:this # TopicExpression IdentifierReference[?Yield, ?Await] Literal ArrayLiteral[?Yield, ?Await] ObjectLiteral[?Yield, ?Await] FunctionExpression ClassExpression[?Yield, ?Await] GeneratorExpression AsyncFunctionExpression AsyncGeneratorExpression RegularExpressionLiteral TemplateLiteral[?Yield, ?Await, ~Tagged] CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]

E.3.1.1 The Topic References

Editor's Note

This section augments the new clause in the core proposal.

Syntax

TopicExpression:# ## ### RestTopicReference:...

The RestTopicReference ... is not itself a TopicExpression; instead, it is used by SpreadElement, PropertyDefinition, and ArgumentList.

E.3.1.1.1 Runtime Semantics: ResolveTopicExpression

Editor's Note

This section is a wholly new sub-clause in addition to the augmentations of the core proposal.

With parameter topicIndex.

Note

This abstract operation constructs, instantiates, then returns a new declarative Lexical Environment for a topic-style pipeline step. It creates an immutable topic binding in that declarative environment using the given topicValues.

  1. Assert: topicIndex is an integer at least 0.
  2. Let envRec be GetTopicEnvironment().
  3. Assert: envRec is a declarative Environment Record.
  4. Assert: envRec.HasTopicBinding() is true.
  5. Assert: topicIndex is less than envRec.[[RestTopicStartIndex]].
  6. Let topicValues be envRec.[[TopicValues]].
  7. Assert: topicValues is a List.
  8. Assert: topicIndex is less than the number of elements of topicValues.
  9. Return envRec.[[TopicValues]].

E.3.1.1.2 Runtime Semantics: CreateRestTopicIteratorRecord

Editor's Note

This section is a wholly new sub-clause in addition to the augmentations of the core proposal.

Note

The RestTopicReference ... is not itself evaluated as a TopicExpression; instead, it is used by SpreadElement, PropertyDefinition, and ArgumentList, by way of calling the CreateRestTopicIteratorRecord abstract operation and using its values.

  1. Let envRec be GetTopicEnvironment().
  2. Assert: envRec is a declarative Environment Record.
  3. Assert: envRec.HasTopicBinding() is true.
  4. Let restTopicStartIndex be envRec.[[RestTopicStartIndex]].
  5. Assert: restTopicStartIndex is an integer at least 0.
  6. Let topicValues be envRec.[[TopicValues]].
  7. Assert: topicValues is a List.
  8. Assert: restTopicStartIndex is no more than the number of elements of topicValues.
  9. Let iteratorRecord be CreateListIteratorRecord(topicValues).
  10. Set iteratorRecord.[[Iterator]].[[ListIteratorNextIndex]] to restTopicStartIndex.
  11. Return iteratorRecord.

E.3.1.1.3 Runtime Semantics: Evaluation

Editor's Note

This section augments the new clause in the core proposal.

Note

The RestTopicReference ... is not itself evaluated as a TopicExpression; instead, it is used by SpreadElement, PropertyDefinition, and ArgumentList, using CreateRestTopicIteratorRecord.

PrimaryExpression:#
  1. Let topicValues be GetTopicValues().
  2. Return topicValues_[0].
  1. Return ? ResolveTopicExpression(0).
TopicExpression:##
  1. Return ? ResolveTopicExpression(1).
TopicExpression:###
  1. Return ? ResolveTopicExpression(2).

E.3.1.2 Array Initializer

Syntax

SpreadElement[Yield, Await]:...AssignmentExpression[+In, ?Yield, ?Await] RestTopicReference

E.3.1.2.1 Runtime Semantics: ArrayAccumulation

With parameters array and nextIndex.

SpreadElement:...AssignmentExpression
  1. Let spreadRef be the result of evaluating AssignmentExpression.
  2. Let spreadObj be ? GetValue(spreadRef).
  3. Let iteratorRecord be ? GetIterator(spreadObj).
  4. Repeat,
    1. Let next be ? IteratorStep(iteratorRecord).
    2. If next is false, return nextIndex.
    3. Let nextValue be ? IteratorValue(next).
    4. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), nextValue).
    5. Assert: status is true.
    6. Let nextIndex be nextIndex + 1.
Note 1

CreateDataProperty is used to ensure that own properties are defined for the array even if the standard built-in Array prototype object has been modified in a manner that would preclude the creation of new own properties using [[Set]].

SpreadElement:RestTopicReference
  1. Let iteratorRecord be ? CreateRestTopicIteratorRecord().
  2. Repeat,
    1. Let next be ? IteratorStep(iteratorRecord).
    2. If next is false, return nextIndex.
    3. Let nextValue be ? IteratorValue(next).
    4. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), nextValue).
    5. Assert: status is true.
    6. Let nextIndex be nextIndex + 1.
Note 2

CreateDataProperty is used to ensure that own properties are defined for the array even if the standard built-in Array prototype object has been modified in a manner that would preclude the creation of new own properties using [[Set]].

E.3.2 Left-Hand-Side Expressions

Syntax

Arguments[Yield, Await]:() (ArgumentList[?Yield, ?Await]) (ArgumentList[?Yield, ?Await],) ArgumentList[Yield, Await]:AssignmentExpression[+In, ?Yield, ?Await] ...AssignmentExpression[+In, ?Yield, ?Await] RestTopicReference ArgumentList[?Yield, ?Await],AssignmentExpression[+In, ?Yield, ?Await] ArgumentList[?Yield, ?Await],...AssignmentExpression[+In, ?Yield, ?Await] ArgumentList[?Yield, ?Await],RestTopicReference

E.3.2.1 Argument Lists

E.3.2.1.1 Static Semantics: ArgumentListMinWidth

Editor's Note

This section is a wholly new sub-clause of the original Argument Lists clause.

Arguments:()
  1. Return the numeric value 0.
ArgumentList:ArgumentExpression
  1. Return the numeric value 1.
ArgumentList:...AssignmentExpression
  1. Return the numeric value 0.
ArgumentList:ArgumentList,ArgumentExpression
  1. Let preceding be the ArgumentListMinWidth of ArgumentList.
  2. Return preceding + 1.
ArgumentList:ArgumentList,...AssignmentExpression
  1. Let preceding be the ArgumentListMinWidth of ArgumentList.
  2. Return preceding + 1.

E.3.2.1.2 Static Semantics: ArgumentListMaxWidth

Editor's Note

This section is a wholly new sub-clause of the original Argument Lists clause.

Arguments:()
  1. Return the numeric value 0.
ArgumentList:ArgumentExpression
  1. Return the numeric value 1.
ArgumentList:...AssignmentExpression RestTopicReference ArgumentList,...AssignmentExpression ArgumentList,RestTopicReference
  1. Return the numeric value Infinity.
ArgumentList:ArgumentList,ArgumentExpression
  1. Let preceding be the ArgumentListMaxWidth of ArgumentList.
  2. Return preceding + 1.
Note

If preceding is Infinity, then preceding + 1 is also Infinity.

E.3.2.1.3 Runtime Semantics: ArgumentListEvaluation

ArgumentList:...AssignmentExpression Editor's Note

This section augments the original ArgumentListEvaluation clause.

  1. Let list be a new empty List.
  2. Let spreadRef be the result of evaluating AssignmentExpression.
  3. Let spreadObj be ? GetValue(spreadRef).
  4. Let iteratorRecord be ? GetIterator(spreadObj).
  5. Repeat,
    1. Let next be ? IteratorStep(iteratorRecord).
    2. If next is false, return list.
    3. Let nextArg be ? IteratorValue(next).
    4. Append nextArg as the last element of list.
ArgumentList:RestTopicReference
  1. Let iteratorRecord be ? CreateRestTopicIteratorRecord().
  2. Repeat,
    1. Let next be ? IteratorStep(iteratorRecord).
    2. If next is false, return list.
    3. Let nextArg be ? IteratorValue(next).
    4. Append nextArg as the last element of list.
ArgumentList:ArgumentList,...AssignmentExpression
  1. Let precedingArgs be ArgumentListEvaluation of ArgumentList.
  2. ReturnIfAbrupt(precedingArgs).
  3. Let spreadRef be the result of evaluating AssignmentExpression.
  4. Let iteratorRecord be ? GetIterator(? GetValue(spreadRef)).
  5. Repeat,
    1. Let next be ? IteratorStep(iteratorRecord).
    2. If next is false, return precedingArgs.
    3. Let nextArg be ? IteratorValue(next).
    4. Append nextArg as the last element of precedingArgs.
ArgumentList:ArgumentList,RestTopicReference
  1. Let precedingArgs be ArgumentListEvaluation of ArgumentList.
  2. ReturnIfAbrupt(precedingArgs).
  3. Let iteratorRecord be ? CreateRestTopicIteratorRecord().
  4. Repeat,
    1. Let next be ? IteratorStep(iteratorRecord).
    2. If next is false, return precedingArgs.
    3. Let nextArg be ? IteratorValue(next).
    4. Append nextArg as the last element of precedingArgs.

E.3.3 Pipe Operator

Editor's Note

This section augments the new clause in the core proposal.

Syntax

PipeExpression[In, Yield, Await]:ConditionalExpression[?In, ?Yield, ?Await] ConditionalExpression[?In, ?Yield, ?Await]|>Pipeline[?In, ?Yield, ?Await] PipelineHead[?In, ?Yield, ?Await]|>Pipeline[?In, ?Yield, ?Await] PipelineHead[In, Yield, Await]:[lookahead ∉ { ( }]ConditionalExpression[?In, ?Yield, ?Await] Arguments[?Yield, ?Await] ...AssignmentExpression[+In, ?Yield, ?Await] Pipeline[In, Yield, Await]:CoverPipelineBareStepAndTopicStep[?In, ?Yield, ?Await] CoverPipelineBareStepAndTopicStep[?In, ?Yield, ?Await]|>Pipeline[?In, ?Yield, ?Await] CoverPipelineBareStepAndTopicStep[In, Yield, Await]:ConditionalExpression[?In, ?Yield, ?Await]

Supplemental Syntax

When processing an instance of the production CoverPipelineBareStepAndTopicStep:ConditionalExpression , the interpretation of ConditionalExpression is refined using the following grammar:

PipelineBareStep:SimpleReference SimpleReference:IdentifierReference SimpleReference.IdentifierName PipelineTopicStep[In, Yield, Await]:[lookahead ∉ { { }]ConditionalExpression[?In, ?Yield, ?Await] [lookahead ∉ { { ( }]ConditionalExpression[?In, ?Yield, ?Await] Arguments[?Yield, ?Await] ...AssignmentExpression[+In, ?Yield, ?Await] RestTopicReference

E.3.3.1 Static Semantics: Early Errors

Editor's Note

This section augments the new clause in the core proposal.

PipelineHead:ConditionalExpression PipelineTopicStep:ConditionalExpression
  1. It is a Syntax Error if ConditionalExpression is covering Arguments.
Pipeline:PipelineHead|>Pipeline
  1. It is a Syntax Error if the ArgumentListMaxWidth of PipelineHead is less than the ExpectedArgumentCount of Pipeline.
  2. It is a Syntax Error if the ArgumentListMinWidth of Pipeline is not 1.
  3. It is a Syntax Error if the ArgumentListMaxWidth of Pipeline is not 1.
Pipeline:CoverPipelineBareStepAndTopicStep|>Pipeline
  1. It is a Syntax Error if the ArgumentListMaxWidth of the CoveredPipelineStep of CoverPipelineBareStepAndTopicStep is less than the ExpectedArgumentCount of Pipeline.
PipelineTopicStep:ConditionalExpression Block
  1. It is a Syntax Error if this PipelineTopicStep Contains # is false.all of the following are true:
    1. The ExpectedArgumentCount of this PipelineTopicStep is the numeric value 0.
    2. This PipelineTopicStep Contains ... is false.
  2. It is a Syntax Error if this PipelineTopicStep is covering a YieldExpression.
  3. It is a Syntax Error if this PipelineTopicStep is covering a PipelineTopicListHead.
Editor's Note

The production PipelineTopicStep:Block above is included only when Additional Feature BP is also included.

E.3.3.2 Static Semantics: ArgumentListMinWidth

Editor's Note

This section is a wholly new sub-clause of the Pipe Operator clause in the core proposal.

Pipeline:CoverPipelineBareStepAndTopicStep
  1. Let pipelineStep be ? CoveredPipelineStep of CoverPipelineBareStepAndTopicStep.
  2. Return ? ArgumentListMinWidth of pipelineStep.
Pipeline:CoverPipelineBareStepAndTopicStep|>Pipeline
  1. Return ? ArgumentListMinWidth of Pipeline.

E.3.3.3 Static Semantics: ArgumentListMaxWidth

Editor's Note

This section is a wholly new sub-clause of the Pipe Operator clause in the core proposal.

Pipeline:CoverPipelineBareStepAndTopicStep
  1. Let pipelineStep be ? CoveredPipelineStep of CoverPipelineBareStepAndTopicStep.
  2. Return ? ArgumentListMaxWidth of pipelineStep.
Pipeline:CoverPipelineBareStepAndTopicStep|>Pipeline
  1. Return ? ArgumentListMaxWidth of Pipeline.

E.3.3.4 Static Semantics: Contains

With parameter symbol.

Editor's Note

This section augments the new clause in the core proposal.

PipelineBareFunction:SimpleReference
  1. If symbol is #TopicExpression or RestTopicReference, return false.
  2. For each child node child of this Parse Node, do
    1. If child is an instance of symbol, return true.
    2. If child is an instance of a nonterminal, then
      1. Let contained be the result of child Contains symbol.
      2. If contained is true, return true.
  3. Return false.

E.3.3.5 Static Semantics: ExpectedArgumentCount

Editor's Note

This section augments the new clause in the core proposal. It is mutually compatible with further modifications by other additional features.

PipelineTopicStep:ConditionalExpression Block
  1. If this PipelineTopicStep Contains ###, then return 3.
  2. Else if this PipelineTopicStep Contains ##, then return 2.
  3. Else if this PipelineTopicStep Contains #, then return 1.Return 1.
  4. Else, return 0.
Editor's Note

The production PipelineTopicStep:Block above is included only when Additional Feature BP is also included.

PipelineTopicStep:ConditionalExpression
  1. Return 1.
PipelineTopicStep:...AssignmentExpression
  1. Return 0.
PipelineTopicStep:...
  1. Return 0.

E.3.3.6 Runtime Semantics: ArgumentListEvaluation

Editor's Note

This section is a wholly new sub-clause in addition to the sub-clauses of the core proposal that extends the syntax-directed operation ArgumentListEvaluation defined in Ecma262.

PipelineHead:ConditionalExpression
  1. Let inputRef be the result of evaluating ConditionalExpression.
  2. Let inputValue be ? GetValue(inputRef).
  3. Return a List containing the one element which is inputValue.

E.3.3.7 Runtime Semantics: PipelineEvaluation

With parameter inputValues.

Editor's Note

This section augments the new clause in the core proposal.

PipelineTopicStep:Arguments ... ...AssignmentExpression
  1. Let oldEnv be the running execution context's Lexical Environment.
  2. Let pipelineStepEnv be New Declarative Environment(oldEnv).
  3. Perform TopicEnvironmentInstantiation(inputValues, pipelineStepEnv).
  4. Set the running execution context's Lexical Environment to pipelineStepEnv.
  5. Let pipelineValue be ArgumentListEvaluation of this PipelineStep.
  6. Set the running execution context's Lexical Environment to oldEnv.
  7. Return a List containing the one element which is pipelineValue.

E.3.3.8 Runtime Semantics: TopicEnvironmentInstantiation

Editor's Note

This section augments the new clause in the core proposal.

TopicEnvironmentInstantiation is performed as follows using arguments code, env, and topicValuestopicValues, and restTopicStartIndex.

  • topicValues is a List of values: env's primary topic reference will be bound to the first value with which env's topic bindings will be established.
  • restStartIndex is either empty or an integer index not exceeding the number of elements of topicValues. If it is empty, RestTopicReference ... will not be bound to anything. Otherwise, RestTopicReference will be bound to a new Array whose elements are those of topicValues starting at restStartIndex's position.
  1. Assert: topicValues is a List.
  2. Assert: restTopicStartIndex is an integer, at least zero, and less than the number of elements of topicValues.
  3. Let envRec be env's Environment Record.
  4. Assert: envRec is a declarative Environment Record.
  5. Assert: envRec.HasTopicBinding() is false.
  6. Assert: envRec.[[TopicValues]] is empty.
  7. Perform ! envRec.BindTopicValues(topicValues, restTopicStartIndex).

E.3.3.9 Runtime Semantics: Evaluation

Editor's Note

This section augments the new clause in the core proposal.

PipeExpression:ConditionalExpressionPipelineHead|>Pipeline
  1. Let inputRef be the result of evaluating ConditionalExpressioninputValues be ? ArgumentListEvaluation of PipelineHead.
  2. Let inputValues be a List containing the one element which is the result of ? GetValue(inputRef).
  3. Let pipelineOutputValues be ? PipelineEvaluation of Pipeline with argument inputValues.
  4. Assert: pipelineOutputValues is a List containing one element.
  5. Return pipelineOutputValues[0].

E.4 ECMAScript Language: Statements and Declarations

E.4.1 Iteration Statements

Editor's Note

E.4.1.1 Static Semantics: Early Errors

IterationStatement:doStatementwhile(Expression); while(Expression)Statement for(Expressionopt;Expressionopt;Expressionopt)Statement for(varVariableDeclarationList;Expressionopt;Expressionopt)Statement for(LexicalDeclarationExpressionopt;Expressionopt)Statement for(LeftHandSideExpressioninExpression)Statement for(varForBindinginExpression)Statement for(ForDeclarationinExpression)Statement for(LeftHandSideExpressionofAssignmentExpression)Statement for(varForBindingofAssignmentExpression)Statement for(ForDeclarationofAssignmentExpression)Statement forawait(LeftHandSideExpressionofAssignmentExpression)Statement forawait(varForBindingofAssignmentExpression)Statement forawait(ForDeclarationofAssignmentExpression)Statement
  1. It is a Syntax Error if Statement Contains # is true.any of the following conditions are true:
    1. Block Contains TopicExpression is true.
    2. Block Contains RestTopicReference is true.
Note

Syntax nonterminals that establish new lexical bindings within new inner program scopes, including iteration statements, may not contain a topic reference #TopicExpression (#, ##, or ###) or a RestTopicReference (...). However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as ConditionalExpression in PipelineTopicStep:ConditionalExpression , which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early error above.

E.4.2 The with statement

E.4.2.1 Static Semantics: Early Errors

Editor's Note WithStatement:with(Expression)Statement
  1. It is a Syntax Error if Statement Contains # is true.any of the following conditions are true:
    1. Block Contains TopicExpression is true.
    2. Block Contains RestTopicReference is true.
Note

Syntax nonterminals that establish new lexical bindings within new inner program scopes, including WithStatement, may not contain a topic reference #TopicExpression (#, ##, or ###) or a RestTopicReference (...). However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as ConditionalExpression in PipelineTopicStep:ConditionalExpression , which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early error above.

E.4.3 The try statement

E.4.3.1 Static Semantics: Early Errors

Editor's Note Catch:catch(CatchParameter)Block
  1. It is a Syntax Error if Block Contains # is true.any of the following conditions are true:
    1. Block Contains TopicExpression is true.
    2. Block Contains RestTopicReference is true.
Note

Syntax nonterminals that establish new lexical bindings within new inner program scopes, including Catch, may not contain a topic reference #TopicExpression (#, ##, or ###) or a RestTopicReference (...). However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as ConditionalExpression in PipelineTopicStep:ConditionalExpression , which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early errors above.

E.5 ECMAScript Language: Functions and Classes

E.5.1 Function Definitions

E.5.1.1 Static Semantics: Early Errors

Editor's Note FunctionBody:FunctionStatementList Note

Arrow functions' ConciseBody may contain the topic reference #a TopicExpression (#, ##, or ###) or a RestTopicReference (...), as long as ConciseBody is within a parse that is also allowed to contain the topic reference. During runtime, such topic references would refer to the outer environment's topic binding. This is not true for the definitions of other types of functions, which may not contain any topic reference.

E.5.2 Arrow Function Definitions

E.5.2.1 Static Semantics: Contains

With parameter symbol.

Editor's Note ArrowFunction:ArrowParameters=>ConciseBody
  1. If symbol is not one of NewTarget, SuperProperty, SuperCall, super, this, or #TopicExpression, or RestTopicReference, return false.
  2. If ArrowParameters Contains symbol is true, return true.
  3. Return ConciseBody Contains symbol.
Note
Normally, Contains does not look inside most function forms. However, Contains is used to detect new.target, this, super, and #TopicExpression (#, ##, or ###), and RestTopicReference (...) usage within an ArrowFunction.

E.5.3 ECMAScript Language: Scripts and Modules

E.5.3.1 Scripts

E.5.3.1.1 Static Semantics: Early Errors

Editor's Note ScriptBody:StatementList
  1. It is a Syntax Error if StatementList Contains # is true.any of the following conditions are true:
    1. Block Contains TopicExpression is true.
    2. Block Contains RestTopicReference is true.
Note

In general, a top-level program scope, including Script, may not contain a topic reference #TopicExpression (#, ##, or ###) or a RestTopicReference (...). However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as ConditionalExpression in PipelineTopicStep:ConditionalExpression , which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early error above.

E.5.3.2 Modules

E.5.3.2.1 Static Semantics: Early Errors

Editor's Note ModuleItem:StatementListItem
  1. It is a Syntax Error if StatementListItem Contains # is true.any of the following conditions are true:
    1. Block Contains TopicExpression is true.
    2. Block Contains RestTopicReference is true.
Note

In general, a top-level program scope, including Module, may not contain a topic reference #. However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as ConditionalExpression in PipelineTopicStep:ConditionalExpression , which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early error above.

F Additional Feature TS: Pipeline try Statements

Not at Stage 0.

F.1 ECMAScript Language: Statements and Declarations

F.1.1 The try statement

Editor's Note

This section adds onto the augmentations in the core proposal to an existing clause. It is also mutually compatible with the specification for optional catch binding.

Syntax

TryStatement[Yield, Await, Return]:tryBlock[?Yield, ?Await, ?Return]Catch[?Yield, ?Await, ?Return] tryBlock[?Yield, ?Await, ?Return]Finally[?Yield, ?Await, ?Return] tryBlock[?Yield, ?Await, ?Return]Catch[?Yield, ?Await, ?Return]Finally[?Yield, ?Await, ?Return] try|>Pipeline[?Yield, ?Await, ?Return];Catch[?Yield, ?Await, ?Return] try|>Pipeline[?Yield, ?Await, ?Return];Finally[?Yield, ?Await, ?Return] try|>Pipeline[?Yield, ?Await, ?Return];Catch[?Yield, ?Await, ?Return]Finally[?Yield, ?Await, ?Return] Catch[Yield, Await, Return]:catch(CatchParameter[?Yield, ?Await])Block[?Yield, ?Await, ?Return] catch|>Pipeline[?Yield, ?Await, ?Return]Pipeline[?Yield, ?Await, ?Return]; Finally[Yield, Await, Return]:finallyBlock[?Yield, ?Await, ?Return] finally|>Pipeline[?Yield, ?Await, ?Return]Pipeline[?Yield, ?Await, ?Return]; Note

The try statement encloses a block of code or a pipeline in which an exceptional condition can occur, such as a runtime error or a throw statement. The catch clause provides the exception-handling code. When a catch clause with a Block catches an exception, its CatchParameter is bound to that exception. When a catch clause with a Pipeline catches an exception, that exception is passed into its Pipeline as its input value.

F.1.1.1 Static Semantics: Early Errors

Editor's Note Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

Catch:catch(CatchParameter)Block
  1. It is a Syntax Error if Block Contains # is true.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

Catch:catch(CatchParameter)Block
  1. It is a Syntax Error if Block Contains # is true.any of the following conditions are true:
    1. Block Contains TopicExpression is true.
    2. Block Contains RestTopicReference is true.
Note

Syntax nonterminals that establish new lexical bindings within new inner program scopes, including Catch, may not contain a topic reference #TopicExpression (#, ##, or ###) or a RestTopicReference (...). However, such topic-forbidding nonterminals may also contain topic-binding nonterminals such as ConditionalExpression in PipelineTopicStep:ConditionalExpression , which would, in turn, hide their own inner topic references from the Contains abstract operation. Within those topic-binding nonterminals, such topic references would therefore not trigger the early errors above.

Editor's Note

The following early errors are inserted only if the augmentations of Additional Feature BP are also performed.

TryStatement:try|>Pipeline;Catch try|>Pipeline;Finally try|>Pipeline;CatchFinally
  1. It is a Syntax Error if the ArgumentListMinWidth of Pipeline is not 1.
  2. It is a Syntax Error if the ArgumentListMaxWidth of Pipeline is not 1.
Catch:catch|>Pipeline
  1. It is a Syntax Error if the ArgumentListMaxWidth of PipelineHead is less than the ExpectedArgumentCount of Pipeline.
  2. It is a Syntax Error if the ArgumentListMinWidth of Pipeline is not 1.
  3. It is a Syntax Error if the ArgumentListMaxWidth of Pipeline is not 1.
Finally:finally|>Pipeline
  1. It is a Syntax Error if the ArgumentListMinWidth of Pipeline is not 1.
  2. It is a Syntax Error if the ArgumentListMaxWidth of Pipeline is not 1.

F.1.1.2 Static Semantics: Contains

With parameter symbol.

Editor's Note

This section is a wholly new sub-clause.

Catch:catch|>Pipeline
  1. If symbol is #, return false.
  2. For each child node child of this Parse Node, do
    1. If child is an instance of symbol, return true.
    2. If child is an instance of a nonterminal, then
      1. Let contained be the result of child Contains symbol.
      2. If contained is true, return true.
  3. Return false.

F.1.1.3 Static Semantics: ContainsDuplicateLabels

With parameter labelSet.

Editor's Note TryStatement:try|>Pipeline;Catch Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return ContainsDuplicateLabels of Catch with argument labelSet.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let hasDuplicates be ContainsDuplicateLabels of Pipeline with argument labelSet.
  2. If hasDuplicates is true, return true.
  3. Return ContainsDuplicateLabels of Catch with argument labelSet.
TryStatement:try|>Pipeline;Finally Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return ContainsDuplicateLabels of Finally with argument labelSet.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let hasDuplicates be ContainsDuplicateLabels of Pipeline with argument labelSet.
  2. If hasDuplicates is true, return true.
  3. Return ContainsDuplicateLabels of Finally with argument labelSet.
TryStatement:try|>Pipeline;CatchFinally Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Let hasDuplicates be ContainsDuplicateLabels of Catch with argument labelSet.
  2. If hasDuplicates is true, return true.
  3. Return ContainsDuplicateLabels of Finally with argument labelSet.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let hasDuplicates be ContainsDuplicateLabels of Pipeline with argument labelSet.
  2. If hasDuplicates is true, return true.
  3. Let hasDuplicates be ContainsDuplicateLabels of Catch with argument labelSet.
  4. If hasDuplicates is true, return true.
  5. Return ContainsDuplicateLabels of Finally with argument labelSet.
Catch:catch|>Pipeline Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return false.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Return ContainsDuplicateLabels of Pipeline with argument labelSet.

F.1.1.4 Static Semantics: ContainsUndefinedBreakTarget

With parameter labelSet.

Editor's Note TryStatement:try|>PipelineCatch Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return ContainsUndefinedBreakTarget of Catch with argument labelSet.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let hasUndefinedLabels be ContainsUndefinedBreakTarget of Pipeline with argument labelSet.
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedBreakTarget of Catch with argument labelSet.
TryStatement:try|>Pipeline;Finally Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return ContainsUndefinedBreakTarget of Finally with argument labelSet.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let hasUndefinedLabels be ContainsUndefinedBreakTarget of Pipeline with argument labelSet.
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedBreakTarget of Finally with argument labelSet.
TryStatement:try|>Pipeline;CatchFinally Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Let hasUndefinedLabels be ContainsUndefinedBreakTarget of Catch with argument labelSet.
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedBreakTarget of Finally with argument labelSet.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let hasUndefinedLabels be ContainsUndefinedBreakTarget of Pipeline with argument labelSet.
  2. If hasUndefinedLabels is true, return true.
  3. Let hasUndefinedLabels be ContainsUndefinedBreakTarget of Catch with argument labelSet.
  4. If hasUndefinedLabels is true, return true.
  5. Return ContainsUndefinedBreakTarget of Finally with argument labelSet.
Catch:catch|>Pipeline Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return false.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Return ContainsUndefinedBreakTarget of Pipeline with argument labelSet.

F.1.1.5 Static Semantics: ContainsUndefinedContinueTarget

With parameters iterationSet and labelSet.

Editor's Note TryStatement:try|>Pipeline;Catch Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return ContainsUndefinedContinueTarget of Catch with arguments iterationSet and « ».
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let hasUndefinedLabels be ContainsUndefinedContinueTarget of Pipeline with arguments iterationSet and « ».
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedContinueTarget of Catch with arguments iterationSet and « ».
TryStatement:try|>Pipeline;Finally Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return ContainsUndefinedContinueTarget of Finally with arguments iterationSet and « ».
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let hasUndefinedLabels be ContainsUndefinedContinueTarget of Pipeline with arguments iterationSet and « ».
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedContinueTarget of Finally with arguments iterationSet and « ».
TryStatement:try|>Pipeline;CatchFinally Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Let hasUndefinedLabels be ContainsUndefinedContinueTarget of Catch with arguments iterationSet and « ».
  2. If hasUndefinedLabels is true, return true.
  3. Return ContainsUndefinedContinueTarget of Finally with arguments iterationSet and « ».
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let hasUndefinedLabels be ContainsUndefinedContinueTarget of Pipeline with arguments iterationSet and « ».
  2. If hasUndefinedLabels is true, return true.
  3. Let hasUndefinedLabels be ContainsUndefinedContinueTarget of Catch with arguments iterationSet and « ».
  4. If hasUndefinedLabels is true, return true.
  5. Return ContainsUndefinedContinueTarget of Finally with arguments iterationSet and « ».
Catch:catch|>Pipeline; Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return false.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Return ContainsUndefinedContinueTarget of Pipeline with arguments iterationSet and « ».

F.1.1.6 Static Semantics: VarDeclaredNames

Editor's Note TryStatement:try|>Pipeline;Catch Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return VarDeclaredNames of Catch.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let names be VarDeclaredNames of Pipeline.
  2. Append to names the elements of the VarDeclaredNames of Catch.
  3. Return names.
TryStatement:try|>Pipeline;Finally Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return the VarDeclaredNames of Finally.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let names be VarDeclaredNames of Pipeline.
  2. Append to names the elements of the VarDeclaredNames of Finally.
  3. Return names.
TryStatement:try|>Pipeline;CatchFinally Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Let names be the VarDeclaredNames of Catch.
  2. Append to names the elements of the VarDeclaredNames of Finally.
  3. Return names.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let names be VarDeclaredNames of Pipeline.
  2. Append to names the elements of the VarDeclaredNames of Catch.
  3. Append to names the elements of the VarDeclaredNames of Finally.
  4. Return names.
Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return « ».
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Return the VarDeclaredNames of Pipeline.

F.1.1.7 Static Semantics: VarScopedDeclarations

Editor's Note TryStatement:try|>Pipeline;Catch Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return the VarScopedDeclarations of Catch.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let declarations be VarScopedDeclarations of Pipeline.
  2. Append to declarations the elements of the VarScopedDeclarations of Catch.
  3. Return declarations.
TryStatement:try|>Pipeline;Finally Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return the VarScopedDeclarations of Finally.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let declarations be VarScopedDeclarations of Pipeline.
  2. Append to declarations the elements of the VarScopedDeclarations of Finally.
  3. Return declarations.
TryStatement:try|>Pipeline;CatchFinally Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Let declarations be the VarScopedDeclarations of Catch.
  2. Append to declarations the elements of the VarScopedDeclarations of Finally.
  3. Return declarations.
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Let declarations be VarScopedDeclarations of Pipeline.
  2. Append to declarations the elements of the VarScopedDeclarations of Catch.
  3. Append to declarations the elements of the VarScopedDeclarations of Finally.
  4. Return declarations.
Catch:catch|>Pipeline; Editor's Note

If the augmentations of Additional Feature BP are not also performed, then the algorithm for this production is the following.

  1. Return « ».
Editor's Note

If the augmentations of Additional Feature BP are also performed, then the algorithm for this production is the following.

  1. Return the VarScopedDeclarations of Pipeline.

F.1.1.8 Runtime Semantics: CatchClauseEvaluation

Editor's Note

This section augments the original CatchClauseEvaluation clause.

With parameter thrownValue.

Catch:catch|>Pipeline;
  1. Let inputValues be a List containing the one element which is thrownValue.
  2. Let pipelineOutputValues be ? PipelineEvaluation of Pipeline with argument inputValues.
  3. Assert: pipelineOutputValues is a List containing one element.
  4. Return Completion(pipelineOutputValues[0]).

F.1.1.9 Runtime Semantics: Evaluation

Editor's Note TryStatement:try|>Pipeline;Catch
  1. Let inputValues be ? GetTopicValues().
  2. Let B be PipelineEvaluation Pipeline with argument inputValues.
  3. If B.[[Type]] is throw, let C be CatchClauseEvaluation of Catch with argument B.[[Value]].
  4. Else, let C be B.
  5. Return Completion(UpdateEmpty(C, undefined)).
TryStatement:try|>Pipeline;Finally
  1. Let inputValues be ? GetTopicValues().
  2. Let B be PipelineEvaluation Pipeline with argument inputValues.
  3. Let F be the result of evaluating Finally.
  4. If F.[[Type]] is normal, set F to B.
  5. Return Completion(UpdateEmpty(F, undefined)).
TryStatement:try|>Pipeline;CatchFinally
  1. Let inputValues be ? GetTopicValues().
  2. Let B be PipelineEvaluation Pipeline with argument inputValues.
  3. If B.[[Type]] is throw, let C be CatchClauseEvaluation of Catch with argument B.[[Value]].
  4. Else, let C be B.
  5. Let F be the result of evaluating Finally.
  6. If F.[[Type]] is normal, set F to C.
  7. Return Completion(UpdateEmpty(F, undefined)).

G Copyright & Software License

Copyright Notice

© 2020 J. S. Choi, Ecma International

Software License

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.