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
  • It is a Syntax Error if the code matched by this production is contained in strict mode code.
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

IdentifierName :: IdentifierStart IdentifierName IdentifierPart
  1. Let idText be the source text matched by IdentifierName.
  2. Let idTextUnescaped be the result of replacing any occurrences of \ UnicodeEscapeSequence in idText with the code point represented by the UnicodeEscapeSequence.
  3. 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.

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.