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.
1 Directive Prologues and the Use Strict Directive
A Directive Prologue is the longest sequence of ExpressionStatement s occurring as the initial StatementListItem s or ModuleItem s 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 ExpressionStatement s of a Directive Prologue are evaluated normally during evaluation of the containing production. Implementations may define implementation specific meanings for ExpressionStatement s 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.
2 Static Semantics: Early Errors
FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody }
FunctionDeclaration : function ( FormalParameters ) { FunctionBody }
FunctionExpression : function BindingIdentifier opt ( FormalParameters ) { FunctionBody }
Note 1
The LexicallyDeclaredNames of a FunctionBody does not include identifiers bound using var or function declarations.
UniqueFormalParameters : FormalParameters
It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements.
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 .
3 Static Semantics: ContainsUseModule
FunctionBody : FunctionStatementList
If the Directive Prologue of FunctionStatementList contains a Use Module Directive , return true ; otherwise, return false .
4 Static Semantics: ContainsUseScript
FunctionBody : FunctionStatementList
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.
5 Static 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.
6 Static Semantics: Early Errors
MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody }
MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody }
The section 14.4.1 Static Semantics: Early Errors is modified as follows.
7 Static Semantics: Early Errors
GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody }
GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody }
GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody }
GeneratorExpression : function * BindingIdentifier opt ( FormalParameters ) { GeneratorBody }
The section 14.6.1 Static Semantics: Early Errors is modified as follows.
8 Static Semantics: Early Errors
AsyncMethod : async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody }
AsyncFunctionDeclaration : async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
AsyncFunctionDeclaration : async [no LineTerminator here] function ( FormalParameters ) { AsyncFunctionBody }
AsyncFunctionExpression : async [no LineTerminator here] function ( FormalParameters ) { AsyncFunctionBody }
AsyncFunctionExpression : async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
The section 14.7.1 Static Semantics: Early Errors is modified as follows.
9 Static 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.
10 Static Semantics: Early Errors
Script : ScriptBody
It is a Syntax Error if the LexicallyDeclaredNames of ScriptBody contains any duplicate entries.
It is a Syntax Error if any element of the LexicallyDeclaredNames of ScriptBody also occurs in the VarDeclaredNames of ScriptBody .
ScriptBody : StatementList
The section 15.2.1.1 Static Semantics: Early Errors are modified as follows.
11 Static 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.