Stage 1 Draft / May 16, 2017

Module/script mode pragmas

The section 14.1.1 Directive Prologues and the Use Strict Directive is modified as follows.

1Directive Prologues and the Use Strict Directive

A Directive Prologue is the longest sequence of ExpressionStatements occurring as the initial StatementListItems or ModuleItems of a FunctionBody, a ScriptBody, or a ModuleBody and where each ExpressionStatement in the sequence consists entirely of a StringLiteral token followed by a semicolon. The semicolon may appear explicitly or may be inserted by automatic semicolon insertion. A Directive Prologue may be an empty sequence.

A Use Strict Directive is an ExpressionStatement in a Directive Prologue whose StringLiteral is either the exact code unit sequences "use strict" or 'use strict'. A Use Strict Directive may not contain an EscapeSequence or LineContinuation.

A Directive Prologue may contain more than one Use Strict Directive. However, an implementation may issue a warning if this occurs.

A Use Module Directive is an ExpressionStatement in a Directive Prologue whose StringLiteral is either the exact code unit sequences "use module" or 'use module'. A Use Module Directive may not contain an EscapeSequence or LineContinuation.

A Directive Prologue may contain more than one Use Module Directive. However, an implementation may issue a warning if this occurs.

A Use Script Directive is an ExpressionStatement in a Directive Prologue whose StringLiteral is either the exact code unit sequences "use script" or 'use script'. A Use Script Directive may not contain an EscapeSequence or LineContinuation.

A Directive Prologue may contain more than one Use Script Directive. However, an implementation may issue a warning if this occurs.

Note

The ExpressionStatements of a Directive Prologue are evaluated normally during evaluation of the containing production. Implementations may define implementation specific meanings for ExpressionStatements which are not a Use Strict Directive and which occur in a Directive Prologue. If an appropriate notification mechanism exists, an implementation should issue a warning if it encounters in a Directive Prologue an ExpressionStatement that is not a Use Strict Directive and which does not have a meaning defined by the implementation.


The section 14.1.2 Static Semantics: Early Errors is modified as follows.

2Static Semantics: Early Errors

FunctionDeclaration:functionBindingIdentifier(FormalParameters){FunctionBody} FunctionDeclaration:function(FormalParameters){FunctionBody} FunctionExpression:functionBindingIdentifieropt(FormalParameters){FunctionBody} Note 1

The LexicallyDeclaredNames of a FunctionBody does not include identifiers bound using var or function declarations.

UniqueFormalParameters:FormalParameters FormalParameters:FormalParameterList Note 2

Multiple occurrences of the same BindingIdentifier in a FormalParameterList is only allowed for functions and generator functions which have simple parameter lists and which are not defined in strict mode code.

FunctionBody:FunctionStatementList

The following new sections are added before 14.1.7 Static Semantics: ExpectedArgumentCount.

3Static Semantics: ContainsUseModule

FunctionBody:FunctionStatementList
  1. If the Directive Prologue of FunctionStatementList contains a Use Module Directive, return true; otherwise, return false.

4Static Semantics: ContainsUseScript

FunctionBody:FunctionStatementList
  1. If the Directive Prologue of FunctionStatementList contains a Use Script Directive, return true; otherwise, return false.

The section 14.2.1 Static Semantics: Early Errors is modified as follows.

5Static Semantics: Early Errors

ArrowFunction:ArrowParameters=>ConciseBody ArrowParameters[Yield, Await]:CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]

The section 14.3.1 Static Semantics: Early Errors is modified as follows.

6Static Semantics: Early Errors

MethodDefinition:PropertyName(UniqueFormalParameters){FunctionBody} MethodDefinition:setPropertyName(PropertySetParameterList){FunctionBody}

The section 14.4.1 Static Semantics: Early Errors is modified as follows.

7Static Semantics: Early Errors

GeneratorMethod:*PropertyName(UniqueFormalParameters){GeneratorBody} GeneratorDeclaration:function*BindingIdentifier(FormalParameters){GeneratorBody} GeneratorDeclaration:function*(FormalParameters){GeneratorBody} GeneratorExpression:function*BindingIdentifieropt(FormalParameters){GeneratorBody}

The section 14.6.1 Static Semantics: Early Errors is modified as follows.

8Static Semantics: Early Errors

AsyncMethod:async[no LineTerminator here]PropertyName(UniqueFormalParameters){AsyncFunctionBody} AsyncFunctionDeclaration:async[no LineTerminator here]functionBindingIdentifier(FormalParameters){AsyncFunctionBody} AsyncFunctionDeclaration:async[no LineTerminator here]function(FormalParameters){AsyncFunctionBody} AsyncFunctionExpression:async[no LineTerminator here]function(FormalParameters){AsyncFunctionBody} AsyncFunctionExpression:async[no LineTerminator here]functionBindingIdentifier(FormalParameters){AsyncFunctionBody}

The section 14.7.1 Static Semantics: Early Errors is modified as follows.

9Static Semantics: Early Errors

AsyncArrowFunction:async[no LineTerminator here]AsyncArrowBindingIdentifier[no LineTerminator here]=>AsyncConciseBody AsyncArrowFunction:CoverCallExpressionAndAsyncArrowHead[no LineTerminator here]=>AsyncConciseBody

The section 15.1.1 Static Semantics: Early Errors is modified as follows.

10Static Semantics: Early Errors

Script:ScriptBody ScriptBody:StatementList

The section 15.2.1.1 Static Semantics: Early Errors are modified as follows.

11Static Semantics: Early Errors

ModuleBody:ModuleItemList Note

The duplicate ExportedNames rule implies that multiple export default ExportDeclaration items within a ModuleBody is a Syntax Error. Additional error conditions relating to conflicting or duplicate declarations are checked during module linking prior to evaluation of a Module. If any such errors are detected the Module is not evaluated.