ECMAScript® 2024 Language Specification

Draft ECMA-262 / February 15, 2024

13.1 Identifiers

Syntax

IdentifierReference[Yield, Await] : Identifier [~Yield] yield [~Await] await BindingIdentifier[Yield, Await] : Identifier yield await LabelIdentifier[Yield, Await] : Identifier [~Yield] yield [~Await] await Identifier : IdentifierName but not ReservedWord Note

yield and await are permitted as BindingIdentifier in the grammar, and prohibited with static semantics below, to prohibit automatic semicolon insertion in cases such as

let
await 0;

13.1.1 Static Semantics: Early Errors

BindingIdentifier : Identifier IdentifierReference : yield BindingIdentifier : yield LabelIdentifier : yield IdentifierReference : await BindingIdentifier : await LabelIdentifier : await BindingIdentifier[Yield, Await] : yield
  • It is a Syntax Error if this production has a [Yield] parameter.
BindingIdentifier[Yield, Await] : await
  • It is a Syntax Error if this production has an [Await] parameter.
IdentifierReference[Yield, Await] : Identifier BindingIdentifier[Yield, Await] : Identifier LabelIdentifier[Yield, Await] : Identifier
  • It is a Syntax Error if this production has a [Yield] parameter and StringValue of Identifier is "yield".
  • It is a Syntax Error if this production has an [Await] parameter and StringValue of Identifier is "await".
Identifier : IdentifierName but not ReservedWord Note

StringValue of IdentifierName normalizes any Unicode escape sequences in IdentifierName hence such escapes cannot be used to write an Identifier whose code point sequence is the same as a ReservedWord.

13.1.2 Static Semantics: StringValue

The syntax-directed operation StringValue takes no arguments and returns a String. It is defined piecewise over the following productions:

IdentifierName :: IdentifierStart IdentifierName IdentifierPart
  1. Let idTextUnescaped be IdentifierCodePoints of IdentifierName.
  2. Return CodePointsToString(idTextUnescaped).
IdentifierReference : yield BindingIdentifier : yield LabelIdentifier : yield
  1. Return "yield".
IdentifierReference : await BindingIdentifier : await LabelIdentifier : await
  1. Return "await".
Identifier : IdentifierName but not ReservedWord
  1. Return the StringValue of IdentifierName.
PrivateIdentifier :: # IdentifierName
  1. Return the string-concatenation of 0x0023 (NUMBER SIGN) and the StringValue of IdentifierName.
ModuleExportName : StringLiteral
  1. Return the SV of StringLiteral.

13.1.3 Runtime Semantics: Evaluation

IdentifierReference : Identifier
  1. Return ? ResolveBinding(StringValue of Identifier).
IdentifierReference : yield
  1. Return ? ResolveBinding("yield").
IdentifierReference : await
  1. Return ? ResolveBinding("await").
Note 1

The result of evaluating an IdentifierReference is always a value of type Reference.

Note 2

In non-strict code, the keyword yield may be used as an identifier. Evaluating the IdentifierReference resolves the binding of yield as if it was an Identifier. Early Error restriction ensures that such an evaluation only can occur for non-strict code.