Multipage preference

Stage 1 Draft / July 24, 2026

Proposal Private Declarations

Contributing to this Proposal

You can discuss this proposal on GitHub.

1 New Syntax

1.1 Private Declarations

Syntax

PrivateDeclaration : private PrivateIdentifier ; StatementListItem[Yield, Await, Return] : Statement[?Yield, ?Await, ?Return] Declaration[?Yield, ?Await] PrivateDeclaration

1.1.1 Static Semantics: Early Errors

PrivateDeclaration : private PrivateIdentifier ; StatementList : StatementListItem StatementList StatementListItem ModuleItemList : ModuleItem ModuleItemList ModuleItem

1.1.2 Runtime Semantics: Evaluation

PrivateDeclaration : private PrivateIdentifier ;
  1. Return empty.

1.2 Objects

1.2.1 Object Initializer

Syntax

PropertyDefinition[Yield, Await] : IdentifierReference[?Yield, ?Await] CoverInitializedName[?Yield, ?Await] PropertyName[?Yield, ?Await] : AssignmentExpression[+In, ?Yield, ?Await] outer [no LineTerminator here] PrivateIdentifier : AssignmentExpression[+In, ?Yield, ?Await] MethodDefinition[?Yield, ?Await] ... AssignmentExpression[+In, ?Yield, ?Await]

1.2.1.1 Static Semantics: Early Errors

ObjectLiteral : { PropertyDefinitionList } { PropertyDefinitionList , }

1.2.1.2 Static Semantics: PrivateNamesUsedInThisObject

The syntax-directed operation PrivateNamesUsedInThisObject takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

ClassElementName : PrivateIdentifier outer PrivateIdentifier
  1. Return a List whose sole element is the StringValue of PrivateIdentifier.
ClassElementName : PropertyName
  1. Return a new empty List.
FieldDefinition : ClassElementName Initializeropt
  1. Return the PrivateNamesUsedInThisObject of ClassElementName.
MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } get ClassElementName ( ) { FunctionBody } set ClassElementName ( PropertySetParameterList ) { FunctionBody } GeneratorMethod : * ClassElementName ( UniqueFormalParameters ) { GeneratorBody } AsyncMethod : async ClassElementName ( UniqueFormalParameters ) { AsyncFunctionBody } AsyncGeneratorMethod : async * ClassElementName ( UniqueFormalParameters ) { AsyncGeneratorBody }
  1. Return the PrivateNamesUsedInThisObject of ClassElementName.
ClassElement : ClassStaticBlock ;
  1. Return a new empty List.
ClassElementList : ClassElementList ClassElement
  1. Let names1 be the PrivateNamesUsedInThisObject of ClassElementList.
  2. Let names2 be the PrivateNamesUsedInThisObject of ClassElement.
  3. Return the list-concatenation of names1 and names2.
PropertyDefinition : outer PrivateIdentifier : AssignmentExpression
  1. Return a List whose sole element is the StringValue of PrivateIdentifier.
PropertyDefinition : IdentifierReference CoverInitializedName PropertyName : AssignmentExpression ... AssignmentExpression
  1. Return a new empty List.
PropertyDefinitionList : PropertyDefinitionList , PropertyDefinition
  1. Let names1 be the PrivateNamesUsedInThisObject of PropertyDefinitionList.
  2. Let names2 be the PrivateNamesUsedInThisObject of PropertyDefinition.
  3. Return the list-concatenation of names1 and names2.

1.2.1.3 Runtime Semantics: PropertyDefinitionEvaluation

The syntax-directed operation PropertyDefinitionEvaluation takes argument obj (an Object) and returns either a normal completion containing unused or an abrupt completion. It is defined piecewise over the following productions:

PropertyDefinition : outer PrivateIdentifier : AssignmentExpression
  1. Let privateEnv be the running execution context's PrivateEnvironment.
  2. Assert: privateEnv is not null.
  3. Let privateName be ResolvePrivateIdentifier(privateEnv, the StringValue of PrivateIdentifier).
  4. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
    1. Let value be ? NamedEvaluation of AssignmentExpression with argument privateName.
  5. Else,
    1. Let valueRef be ? Evaluation of AssignmentExpression.
    2. Let value be ? GetValue(valueRef).
  6. Perform ? PrivateFieldAdd(obj, privateName, value).
  7. Return unused.
PropertyDefinition : MethodDefinition
  1. Perform ? MethodDefinitionEvaluation of MethodDefinition with arguments obj and true.
  2. Let method be ? MethodDefinitionEvaluation of MethodDefinition with arguments obj and true.
  3. If method is a PrivateElement, then
    1. If method.[[Kind]] is accessor, then
      1. Let existing be PrivateElementFind(obj, method.[[Key]]).
      2. If existing is not empty, then
        1. Assert: existing.[[Kind]] is accessor.
        2. If method.[[Getter]] is undefined, then
          1. Assert: existing.[[Setter]] is undefined.
          2. Let combined be PrivateElement { [[Key]]: method.[[Key]], [[Kind]]: accessor, [[Getter]]: existing.[[Getter]], [[Setter]]: method.[[Setter]] }.
        3. Else,
          1. Assert: existing.[[Getter]] is undefined.
          2. Let combined be PrivateElement { [[Key]]: method.[[Key]], [[Kind]]: accessor, [[Getter]]: method.[[Getter]], [[Setter]]: existing.[[Setter]] }.
        4. Replace existing in obj.[[PrivateElements]] with combined.
        5. Return unused.
    2. Perform ? PrivateMethodOrAccessorAdd(obj, method).
  4. Return unused.

1.3 Classes

1.3.1 Class Definitions

Syntax

ClassElementName[Yield, Await] : PropertyName[?Yield, ?Await] PrivateIdentifier outer [no LineTerminator here] PrivateIdentifier

1.3.1.1 Static Semantics: AllPrivateIdentifiersValid

The syntax-directed operation AllPrivateIdentifiersValid takes argument names (a List of Strings) and returns a Boolean. It is defined piecewise over the following productions:

ClassElementName : outer PrivateIdentifier
  1. If names contains the StringValue of PrivateIdentifier, return true.
  2. Return false.
PropertyDefinition : outer PrivateIdentifier : AssignmentExpression
  1. If names does not contain the StringValue of PrivateIdentifier, return false.
  2. Return AllPrivateIdentifiersValid of AssignmentExpression with argument names.
Block : { StatementList }
  1. Let newNames be a copy of names.
  2. Set newNames to the list-concatenation of newNames and the PrivateBoundIdentifiers of StatementList.
  3. Return AllPrivateIdentifiersValid of StatementList with argument newNames.
FunctionBody : FunctionStatementList
  1. Let newNames be a copy of names.
  2. Set newNames to the list-concatenation of newNames and the PrivateBoundIdentifiers of FunctionStatementList.
  3. Return AllPrivateIdentifiersValid of FunctionStatementList with argument newNames.
ScriptBody : StatementList
  1. Let newNames be a copy of names.
  2. Set newNames to the list-concatenation of newNames and the PrivateBoundIdentifiers of StatementList.
  3. Return AllPrivateIdentifiersValid of StatementList with argument newNames.
ModuleBody : ModuleItemList
  1. Let newNames be a copy of names.
  2. Set newNames to the list-concatenation of newNames and the PrivateBoundIdentifiers of ModuleItemList.
  3. Return AllPrivateIdentifiersValid of ModuleItemList with argument newNames.
ClassStaticBlockBody : ClassStaticBlockStatementList
  1. Let newNames be a copy of names.
  2. Set newNames to the list-concatenation of newNames and the PrivateBoundIdentifiers of ClassStaticBlockStatementList.
  3. Return AllPrivateIdentifiersValid of ClassStaticBlockStatementList with argument newNames.

1.3.1.2 Static Semantics: Early Errors

ClassBody : ClassElementList

1.3.1.3 Static Semantics: PrivateNamesUsedInThisClassBody

The syntax-directed operation PrivateNamesUsedInThisClassBody takes argument static (a Boolean) and returns a List of Strings. It is defined piecewise over the following productions:

ClassElementList : ClassElementList ClassElement
  1. Let names1 be the PrivateNamesUsedInThisClassBody of ClassElementList with argument static.
  2. Let names2 be the PrivateNamesUsedInThisClassBody of ClassElement with argument static.
  3. Return the list-concatenation of names1 and names2.
ClassElement : MethodDefinition FieldDefinition ;
  1. If static is true, return a new empty List.
  2. Return the PrivateNamesUsedInThisObject of this ClassElement.
ClassElement : static MethodDefinition static FieldDefinition ;
  1. If static is false, return a new empty List.
  2. Return the PrivateNamesUsedInThisObject of this ClassElement.
ClassElement : ClassStaticBlock ;
  1. Return a new empty List.

1.3.1.4 Static Semantics: PrivateBoundIdentifiers

The syntax-directed operation PrivateBoundIdentifiers takes no arguments and returns a List of Strings.

Editor's Note
Probably rename this to “CreatedPrivateNames”.

It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. Let names1 be the PrivateBoundIdentifiers of StatementList.
  2. Let names2 be the PrivateBoundIdentifiers of StatementListItem.
  3. Return the list-concatenation of names1 and names2.
StatementListItem : Statement Declaration
  1. Return a new empty List.
ModuleItemList : ModuleItemList ModuleItem
  1. Let names1 be the PrivateBoundIdentifiers of ModuleItemList.
  2. Let names2 be the PrivateBoundIdentifiers of ModuleItem.
  3. Return the list-concatenation of names1 and names2.
ModuleItem : ImportDeclaration ExportDeclaration
  1. Return a new empty List.
FunctionStatementList : [empty] ClassStaticBlockStatementList : [empty] Script : [empty] Module : [empty] ExpressionBody : AssignmentExpression
  1. Return a new empty List.
PrivateDeclaration : private PrivateIdentifier ;
  1. Return a List whose sole element is the StringValue of PrivateIdentifier.
ClassElementName : outer PrivateIdentifier
  1. Return a new empty List.

1.3.1.5 Runtime Semantics: Evaluation

ClassElementName : outer PrivateIdentifier
  1. Let privateIdentifier be the StringValue of PrivateIdentifier.
  2. Let privateEnv be the running execution context's PrivateEnvironment.
  3. Assert: privateEnv is not null.
  4. Return ResolvePrivateIdentifier(privateEnv, privateIdentifier).

1.4 Switch

1.4.1 The switch Statement

1.4.1.1 Static Semantics: Early Errors

CaseClause : case Expression : StatementList DefaultClause : default : StatementList

2 Modified Abstract Operations

2.1 PrepareForOrdinaryCall ( func, newTarget )

The abstract operation PrepareForOrdinaryCall takes arguments func (an ECMAScript function object) and newTarget (an Object or undefined) and returns an execution context. It performs the following steps when called:

  1. Let callerContext be the running execution context.
  2. Let calleeContext be a new ECMAScript code execution context.
  3. Set the Function of calleeContext to func.
  4. Let calleeRealm be func.[[Realm]].
  5. Set the Realm of calleeContext to calleeRealm.
  6. Set the ScriptOrModule of calleeContext to func.[[ScriptOrModule]].
  7. Let localEnv be NewFunctionEnvironment(func, newTarget).
  8. Set the LexicalEnvironment of calleeContext to localEnv.
  9. Set the VariableEnvironment of calleeContext to localEnv.
  10. Set the PrivateEnvironment of calleeContext to func.[[PrivateEnvironment]].
  11. NOTE: A new PrivateEnvironment is created in FunctionDeclarationInstantiation so that expressions in the parameter list do not have visibility of private names declared in the function body.
  12. If callerContext is not already suspended, suspend callerContext.
  13. Push calleeContext onto the execution context stack; calleeContext is now the running execution context.
  14. NOTE: Any exception objects produced after this point are associated with calleeRealm.
  15. Return calleeContext.

2.2 FunctionDeclarationInstantiation ( func, argList )

The abstract operation FunctionDeclarationInstantiation takes arguments func (an ECMAScript function object) and argList (a List of ECMAScript language values) and returns either a normal completion containing unused or a throw completion. func is the function object for which the execution context is being established.

Note

When an execution context is established for evaluating an ECMAScript function a new Function Environment Record is created and bindings for each formal parameter are instantiated in that Environment Record. Each declaration in the function body is also instantiated. If the function's formal parameters do not include any default value initializers then the body declarations are instantiated in the same Environment Record as the parameters. If default value parameter initializers exist, a second Environment Record is created for the body declarations. Formal parameters and functions are initialized as part of FunctionDeclarationInstantiation. All other bindings are initialized during evaluation of the function body.

It performs the following steps when called:

  1. Let calleeContext be the running execution context.
  2. Let code be func.[[ECMAScriptCode]].
  3. Let strict be func.[[Strict]].
  4. Let formals be func.[[FormalParameters]].
  5. Let paramNames be the BoundNames of formals.
  6. If paramNames has any duplicate entries, let hasDuplicates be true; else let hasDuplicates be false.
  7. Let simpleParamList be IsSimpleParameterList of formals.
  8. Let hasParamExprs be ContainsExpression of formals.
  9. Let variableNames be the VarDeclaredNames of code.
  10. Let variableDecls be the VarScopedDeclarations of code.
  11. Let lexicalNames be the LexicallyDeclaredNames of code.
  12. Let funcNames be a new empty List.
  13. Let funcsToInitialize be a new empty List.
  14. For each element variableDecl of variableDecls, in reverse List order, do
    1. If variableDecl is neither a VariableDeclaration nor a ForBinding nor a BindingIdentifier, then
      1. Assert: variableDecl is either a FunctionDeclaration, a GeneratorDeclaration, an AsyncFunctionDeclaration, or an AsyncGeneratorDeclaration.
      2. Let funcName be the sole element of the BoundNames of variableDecl.
      3. If funcNames does not contain funcName, then
        1. Insert funcName as the first element of funcNames.
        2. NOTE: If there are multiple function declarations for the same name, the last declaration is used.
        3. Insert variableDecl as the first element of funcsToInitialize.
  15. Let argumentsObjNeeded be true.
  16. If func.[[ThisMode]] is lexical, then
    1. NOTE: Arrow functions never have an arguments object.
    2. Set argumentsObjNeeded to false.
  17. Else if paramNames contains "arguments", then
    1. Set argumentsObjNeeded to false.
  18. Else if hasParamExprs is false, then
    1. If funcNames contains "arguments" or lexicalNames contains "arguments", then
      1. Set argumentsObjNeeded to false.
  19. If strict is true or hasParamExprs is false, then
    1. NOTE: Only a single Environment Record is needed for the parameters, since calls to eval in strict mode code cannot create new bindings which are visible outside of the eval.
    2. Let envRecord be the LexicalEnvironment of calleeContext.
  20. Else,
    1. NOTE: A separate Environment Record is needed to ensure that bindings created by direct eval calls in the formal parameter list are outside the environment where parameters are declared.
    2. Let calleeEnv be the LexicalEnvironment of calleeContext.
    3. Let envRecord be NewDeclarativeEnvironment(calleeEnv).
    4. Assert: The VariableEnvironment of calleeContext and calleeEnv are the same Environment Record.
    5. Set the LexicalEnvironment of calleeContext to envRecord.
  21. For each String paramName of paramNames, do
    1. Let alreadyDeclared be ! envRecord.HasBinding(paramName).
    2. NOTE: Early errors ensure that duplicate parameter names can only occur in non-strict functions that do not have parameter default values or rest parameters.
    3. If alreadyDeclared is false, then
      1. Perform ! envRecord.CreateMutableBinding(paramName, false).
      2. If hasDuplicates is true, then
        1. Perform ! envRecord.InitializeBinding(paramName, undefined).
  22. If argumentsObjNeeded is true, then
    1. If strict is true or simpleParamList is false, then
      1. Let argumentsObj be CreateUnmappedArgumentsObject(argList).
    2. Else,
      1. NOTE: A mapped argument object is only provided for non-strict functions that don't have a rest parameter, any parameter default value initializers, or any destructured parameters.
      2. Let argumentsObj be CreateMappedArgumentsObject(func, formals, argList, envRecord).
    3. If strict is true, then
      1. Perform ! envRecord.CreateImmutableBinding("arguments", false).
      2. NOTE: In strict mode code early errors prevent attempting to assign to this binding, so its mutability is not observable.
    4. Else,
      1. Perform ! envRecord.CreateMutableBinding("arguments", false).
    5. Perform ! envRecord.InitializeBinding("arguments", argumentsObj).
    6. Let paramBindings be the list-concatenation of paramNames and « "arguments" ».
  23. Else,
    1. Let paramBindings be paramNames.
  24. Let iteratorRecord be CreateListIteratorRecord(argList).
  25. If hasDuplicates is true, then
    1. Let usedEnv be undefined.
  26. Else,
    1. Let usedEnv be envRecord.
  27. NOTE: The following step cannot return a ReturnCompletion because the only way such a completion can arise in expression position is by use of YieldExpression, which is forbidden in parameter lists by Early Error rules in 15.5.1 and 15.6.1.
  28. Perform ? IteratorBindingInitialization of formals with arguments iteratorRecord and usedEnv.
  29. Let privateBoundIdentifiers be the PrivateBoundIdentifiers of code.
  30. Let calleePrivateEnv be the PrivateEnvironment of calleeContext.
  31. Let privateEnv be NewPrivateEnvironment(calleePrivateEnv).
  32. Set the PrivateEnvironment of calleeContext to privateEnv.
  33. Perform AddPrivateNames(privateEnv, privateBoundIdentifiers).
  34. If hasParamExprs is false, then
    1. NOTE: Only a single Environment Record is needed for the parameters and top-level vars.
    2. Let instantiatedVariableNames be a copy of the List paramBindings.
    3. For each element name of variableNames, do
      1. If instantiatedVariableNames does not contain name, then
        1. Append name to instantiatedVariableNames.
        2. Perform ! envRecord.CreateMutableBinding(name, false).
        3. Perform ! envRecord.InitializeBinding(name, undefined).
    4. Let variableEnv be envRecord.
  35. Else,
    1. NOTE: A separate Environment Record is needed to ensure that closures created by expressions in the formal parameter list do not have visibility of declarations in the function body.
    2. Let variableEnv be NewDeclarativeEnvironment(envRecord).
    3. Set the VariableEnvironment of calleeContext to variableEnv.
    4. Let instantiatedVariableNames be a new empty List.
    5. For each element name of variableNames, do
      1. If instantiatedVariableNames does not contain name, then
        1. Append name to instantiatedVariableNames.
        2. Perform ! variableEnv.CreateMutableBinding(name, false).
        3. If paramBindings does not contain name or funcNames contains name, then
          1. Let initialValue be undefined.
        4. Else,
          1. Let initialValue be ! envRecord.GetBindingValue(name, false).
        5. Perform ! variableEnv.InitializeBinding(name, initialValue).
        6. NOTE: A var with the same name as a formal parameter initially has the same value as the corresponding initialized parameter.
  36. If strict is true, then
    1. Let lexicalEnv be variableEnv.
  37. Else,
    1. If the host is a web browser or otherwise supports Block-Level Function Declarations Web Legacy Compatibility Semantics, then
      1. For each FunctionDeclaration funcDecl that is directly contained in the StatementList of any Block, CaseClause, or DefaultClause x such that code Contains x is true, do
        1. Let funcName be the StringValue of the BindingIdentifier of funcDecl.
        2. If replacing the FunctionDeclaration funcDecl with a VariableStatement that has funcName as a BindingIdentifier would not produce any Early Errors for func and paramNames does not contain funcName, then
          1. NOTE: A var binding for funcName is only instantiated here if it is neither a VarDeclaredName, the name of a formal parameter, or another FunctionDeclaration.
          2. If instantiatedVariableNames does not contain funcName and funcName is not "arguments", then
            1. Perform ! variableEnv.CreateMutableBinding(funcName, false).
            2. Perform ! variableEnv.InitializeBinding(funcName, undefined).
            3. Append funcName to instantiatedVariableNames.
          3. When the FunctionDeclaration funcDecl is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 15.2.6:
            1. Let funcEnv be the running execution context's VariableEnvironment.
            2. Let blockEnv be the running execution context's LexicalEnvironment.
            3. Let funcObj be ! blockEnv.GetBindingValue(funcName, false).
            4. Perform ! funcEnv.SetMutableBinding(funcName, funcObj, false).
            5. Return unused.
    2. Let lexicalEnv be NewDeclarativeEnvironment(variableEnv).
    3. NOTE: Non-strict functions use a separate Environment Record for top-level lexical declarations so that a direct eval can determine whether any var scoped declarations introduced by the eval code conflict with pre-existing top-level lexically scoped declarations. This is not needed for strict functions because a strict direct eval always places all declarations into a new Environment Record.
  38. Set the LexicalEnvironment of calleeContext to lexicalEnv.
  39. Let lexicalDecls be the LexicallyScopedDeclarations of code.
  40. For each element lexicalDecl of lexicalDecls, do
    1. NOTE: A lexically declared name cannot be the same as a function/generator declaration, formal parameter, or a var name. Lexically declared names are only instantiated here but not initialized.
    2. For each element name of the BoundNames of lexicalDecl, do
      1. If IsConstantDeclaration of lexicalDecl is true, then
        1. Perform ! lexicalEnv.CreateImmutableBinding(name, true).
      2. Else,
        1. Perform ! lexicalEnv.CreateMutableBinding(name, false).
  41. Let privateEnv be the PrivateEnvironment of calleeContext.
  42. For each Parse Node funcDecl of funcsToInitialize, do
    1. Let funcName be the sole element of the BoundNames of funcDecl.
    2. Let funcObj be InstantiateFunctionObject of funcDecl with arguments lexicalEnv and privateEnv.
    3. Perform ! variableEnv.SetMutableBinding(funcName, funcObj, false).
  43. Return unused.

2.3 InitializeEnvironment ( )

The InitializeEnvironment concrete method of a Source Text Module Record module takes no arguments and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. For each ExportEntry Record exportEntry of module.[[IndirectExportEntries]], do
    1. Assert: exportEntry.[[ExportName]] is not null.
    2. Let resolution be module.ResolveExport(exportEntry.[[ExportName]]).
    3. If resolution is either null or ambiguous, throw a SyntaxError exception.
    4. Assert: resolution is a ResolvedBinding Record.
  2. Assert: All named exports from module are resolvable.
  3. Let realm be module.[[Realm]].
  4. Assert: realm is not undefined.
  5. Let envRecord be NewModuleEnvironment(realm.[[GlobalEnv]]).
  6. Set module.[[Environment]] to envRecord.
  7. For each ImportEntry Record importEntry of module.[[ImportEntries]], do
    1. Let importedModule be GetImportedModule(module, importEntry.[[ModuleRequest]]).
    2. If importEntry.[[ImportName]] is namespace, then
      1. Let namespace be GetModuleNamespace(importedModule).
      2. Perform ! envRecord.CreateImmutableBinding(importEntry.[[LocalName]], true).
      3. Perform ! envRecord.InitializeBinding(importEntry.[[LocalName]], namespace).
    3. Else,
      1. Assert: importEntry.[[ImportName]] is a String.
      2. Let resolution be importedModule.ResolveExport(importEntry.[[ImportName]]).
      3. If resolution is either null or ambiguous, throw a SyntaxError exception.
      4. If resolution.[[BindingName]] is namespace, then
        1. Let namespace be GetModuleNamespace(resolution.[[Module]]).
        2. Perform ! envRecord.CreateImmutableBinding(importEntry.[[LocalName]], true).
        3. Perform ! envRecord.InitializeBinding(importEntry.[[LocalName]], namespace).
      5. Else,
        1. Perform CreateImportBinding(envRecord, importEntry.[[LocalName]], resolution.[[Module]], resolution.[[BindingName]]).
  8. Let moduleContext be a new ECMAScript code execution context.
  9. Set the Function of moduleContext to null.
  10. Assert: module.[[Realm]] is not undefined.
  11. Set the Realm of moduleContext to module.[[Realm]].
  12. Set the ScriptOrModule of moduleContext to module.
  13. Set the VariableEnvironment of moduleContext to module.[[Environment]].
  14. Set the LexicalEnvironment of moduleContext to module.[[Environment]].
  15. Set the PrivateEnvironment of moduleContext to nullNewPrivateEnvironment(null).
  16. Set module.[[Context]] to moduleContext.
  17. Push moduleContext onto the execution context stack; moduleContext is now the running execution context.
  18. Let code be module.[[ECMAScriptCode]].
  19. Let privateEnv be the PrivateEnvironment of moduleContext.
  20. Let privateBoundIdentifiers be the PrivateBoundIdentifiers of code.
  21. Perform AddPrivateNames(privateEnv, privateBoundIdentifiers).
  22. Let variableDecls be the VarScopedDeclarations of code.
  23. Let declaredVariableNames be a new empty List.
  24. For each element variableDecl of variableDecls, do
    1. For each element name of the BoundNames of variableDecl, do
      1. If declaredVariableNames does not contain name, then
        1. Perform ! envRecord.CreateMutableBinding(name, false).
        2. Perform ! envRecord.InitializeBinding(name, undefined).
        3. Append name to declaredVariableNames.
  25. Let lexicalDecls be the LexicallyScopedDeclarations of code.
  26. Let privateEnv be null.
  27. For each element lexicalDecl of lexicalDecls, do
    1. For each element name of the BoundNames of lexicalDecl, do
      1. If IsConstantDeclaration of lexicalDecl is true, then
        1. Perform ! envRecord.CreateImmutableBinding(name, true).
      2. Else,
        1. Perform ! envRecord.CreateMutableBinding(name, false).
      3. If lexicalDecl is either a FunctionDeclaration, a GeneratorDeclaration, an AsyncFunctionDeclaration, or an AsyncGeneratorDeclaration, then
        1. Let funcObj be InstantiateFunctionObject of lexicalDecl with arguments envRecord and privateEnv.
        2. Perform ! envRecord.InitializeBinding(name, funcObj).
  28. Remove moduleContext from the execution context stack.
  29. Return unused.

2.4 ScriptEvaluation ( scriptRecord )

The abstract operation ScriptEvaluation takes argument scriptRecord (a Script Record) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It performs the following steps when called:

  1. Let globalEnv be scriptRecord.[[Realm]].[[GlobalEnv]].
  2. Let scriptContext be a new ECMAScript code execution context.
  3. Set the Function of scriptContext to null.
  4. Set the Realm of scriptContext to scriptRecord.[[Realm]].
  5. Set the ScriptOrModule of scriptContext to scriptRecord.
  6. Set the VariableEnvironment of scriptContext to globalEnv.
  7. Set the LexicalEnvironment of scriptContext to globalEnv.
  8. Set the PrivateEnvironment of scriptContext to nullNewPrivateEnvironment(null).
  9. Suspend the running execution context.
  10. Push scriptContext onto the execution context stack; scriptContext is now the running execution context.
  11. Let scriptNode be scriptRecord.[[ECMAScriptCode]].
  12. Let privateEnv be the PrivateEnvironment of scriptContext.
  13. Let result be Completion(GlobalDeclarationInstantiation(scriptNode, globalEnv, privateEnv)).
  14. If result is a normal completion, then
    1. Set result to Completion(Evaluation of scriptNode).
    2. If result is a normal completion and result.[[Value]] is empty, then
      1. Set result to NormalCompletion(undefined).
  15. Suspend scriptContext and remove it from the execution context stack.
  16. Assert: The execution context stack is not empty.
  17. Resume the context that is now on the top of the execution context stack as the running execution context.
  18. Return ? result.

2.5 GlobalDeclarationInstantiation ( script, envRecord, privateEnv )

The abstract operation GlobalDeclarationInstantiation takes arguments script (a Script Parse Node), envRecord (a Global Environment Record), and privateEnv (a PrivateEnvironment Record) and returns either a normal completion containing unused or a throw completion. script is the Script for which the execution context is being established. envRecord is the global environment in which bindings are to be created. privateEnv is the private environment in which private names are to be created.

Note 1

When an execution context is established for evaluating scripts, declarations are instantiated in the current global environment. Each global binding declared in the code is instantiated.

It performs the following steps when called:

  1. Let privateBoundIdentifiers be the PrivateBoundIdentifiers of script.
  2. Perform AddPrivateNames(privateEnv, privateBoundIdentifiers).
  3. Let lexicalNames be the LexicallyDeclaredNames of script.
  4. Let variableNames be the VarDeclaredNames of script.
  5. For each element name of lexicalNames, do
    1. If HasLexicalDeclaration(envRecord, name) is true, throw a SyntaxError exception.
    2. Let hasRestrictedGlobal be ? HasRestrictedGlobalProperty(envRecord, name).
    3. NOTE: Global var and function bindings (except those that are introduced by non-strict direct eval) are non-configurable and are therefore restricted global properties.
    4. If hasRestrictedGlobal is true, throw a SyntaxError exception.
  6. For each element name of variableNames, do
    1. If HasLexicalDeclaration(envRecord, name) is true, throw a SyntaxError exception.
  7. Let variableDecls be the VarScopedDeclarations of script.
  8. Let funcsToInitialize be a new empty List.
  9. Let declaredFuncNames be a new empty List.
  10. For each element variableDecl of variableDecls, in reverse List order, do
    1. If variableDecl is not either a VariableDeclaration, a ForBinding, or a BindingIdentifier, then
      1. Assert: variableDecl is either a FunctionDeclaration, a GeneratorDeclaration, an AsyncFunctionDeclaration, or an AsyncGeneratorDeclaration.
      2. NOTE: If there are multiple function declarations for the same name, the last declaration is used.
      3. Let funcName be the sole element of the BoundNames of variableDecl.
      4. If declaredFuncNames does not contain funcName, then
        1. Let funcDefinable be ? CanDeclareGlobalFunction(envRecord, funcName).
        2. If funcDefinable is false, throw a TypeError exception.
        3. Append funcName to declaredFuncNames.
        4. Insert variableDecl as the first element of funcsToInitialize.
  11. Let declaredVariableNames be a new empty List.
  12. For each element variableDecl of variableDecls, do
    1. If variableDecl is either a VariableDeclaration, a ForBinding, or a BindingIdentifier, then
      1. For each String name of the BoundNames of variableDecl, do
        1. If declaredFuncNames does not contain name, then
          1. Let variableDefinable be ? CanDeclareGlobalVar(envRecord, name).
          2. If variableDefinable is false, throw a TypeError exception.
          3. If declaredVariableNames does not contain name, then
            1. Append name to declaredVariableNames.
  13. NOTE: No abnormal terminations occur after this algorithm step if the global object is an ordinary object. However, if the global object is a Proxy exotic object it may exhibit behaviours that cause abnormal terminations in some of the following steps.
  14. If the host is a web browser or otherwise supports Block-Level Function Declarations Web Legacy Compatibility Semantics, then
    1. Let strict be ScriptIsStrict of script.
    2. If strict is false, then
      1. Let declaredFuncOrVariableNames be the list-concatenation of declaredFuncNames and declaredVariableNames.
      2. For each FunctionDeclaration funcDecl that is directly contained in the StatementList of any Block, CaseClause, or DefaultClause x such that script Contains x is true, do
        1. Let funcName be the StringValue of the BindingIdentifier of funcDecl.
        2. If replacing the FunctionDeclaration funcDecl with a VariableStatement that has funcName as a BindingIdentifier would not produce any Early Errors for script, then
          1. If HasLexicalDeclaration(envRecord, funcName) is false, then
            1. Let funcDefinable be ? CanDeclareGlobalVar(envRecord, funcName).
            2. If funcDefinable is true, then
              1. NOTE: A var binding for funcName is only instantiated here if it is neither a VarDeclaredName nor the name of another FunctionDeclaration.
              2. If declaredFuncOrVariableNames does not contain funcName, then
                1. Perform ? CreateGlobalVarBinding(envRecord, funcName, false).
                2. Append funcName to declaredFuncOrVariableNames.
              3. When the FunctionDeclaration funcDecl is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 15.2.6:
                1. Let globalEnv be the running execution context's VariableEnvironment.
                2. Let blockEnv be the running execution context's LexicalEnvironment.
                3. Let funcObj be ! blockEnv.GetBindingValue(funcName, false).
                4. Perform ? globalEnv.SetMutableBinding(funcName, funcObj, false).
                5. Return unused.
  15. Let lexicalDecls be the LexicallyScopedDeclarations of script.
  16. Let privateEnv be null.
  17. For each element lexicalDecl of lexicalDecls, do
    1. NOTE: Lexically declared names are only instantiated here but not initialized.
    2. For each element name of the BoundNames of lexicalDecl, do
      1. If IsConstantDeclaration of lexicalDecl is true, then
        1. Perform ? envRecord.CreateImmutableBinding(name, true).
      2. Else,
        1. Perform ? envRecord.CreateMutableBinding(name, false).
  18. For each Parse Node funcDecl of funcsToInitialize, do
    1. Let funcName be the sole element of the BoundNames of funcDecl.
    2. Let funcObj be InstantiateFunctionObject of funcDecl with arguments envRecord and privateEnv.
    3. Perform ? CreateGlobalFunctionBinding(envRecord, funcName, funcObj, false).
  19. For each String variableName of declaredVariableNames, do
    1. Perform ? CreateGlobalVarBinding(envRecord, variableName, false).
  20. Return unused.
Note 2

Early errors specified in 16.1.1 prevent name conflicts between function/var declarations and let/const/class declarations as well as redeclaration of let/const/class bindings for declaration contained within a single Script. However, such conflicts and redeclarations that span more than one Script are detected as runtime errors during GlobalDeclarationInstantiation. If any such errors are detected, no bindings are instantiated for the script. However, if the global object is defined using Proxy exotic objects then the runtime tests for conflicting declarations may be unreliable resulting in an abrupt completion and some global declarations not being instantiated. If this occurs, the code for the Script is not evaluated.

Unlike explicit var or function declarations, properties that are directly created on the global object result in global bindings that may be shadowed by let/const/class declarations.

2.6 PerformEval ( source, strictCaller, direct )

The abstract operation PerformEval takes arguments source (an ECMAScript language value), strictCaller (a Boolean), and direct (a Boolean) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. Assert: If direct is false, then strictCaller is also false.
  2. If source is not a String, return source.
  3. Let evalRealm be the current Realm Record.
  4. NOTE: In the case of a direct eval, evalRealm is the realm of both the caller of eval and of the eval function itself.
  5. Perform ? HostEnsureCanCompileStrings(evalRealm, « », source, direct).
  6. Let inFunc be false.
  7. Let inMethod be false.
  8. Let inDerivedCtor be false.
  9. Let inClassFieldInitializer be false.
  10. If direct is true, then
    1. Let thisEnvRecord be GetThisEnvironment().
    2. If thisEnvRecord is a Function Environment Record, then
      1. Let func be thisEnvRecord.[[FunctionObject]].
      2. Set inFunc to true.
      3. Set inMethod to thisEnvRecord.HasSuperBinding().
      4. If func.[[ConstructorKind]] is derived, set inDerivedCtor to true.
      5. Let classFieldInitializerName be func.[[ClassFieldInitializerName]].
      6. If classFieldInitializerName is not empty, set inClassFieldInitializer to true.
  11. Perform the following substeps in an implementation-defined order, possibly interleaving parsing and error detection:
    1. Let script be ParseText(source, Script).
    2. If script is a List of errors, throw a SyntaxError exception.
    3. If script Contains ScriptBody is false, return undefined.
    4. Let body be the ScriptBody of script.
    5. If inFunc is false and body Contains NewTarget, throw a SyntaxError exception.
    6. If inMethod is false and body Contains SuperProperty, throw a SyntaxError exception.
    7. If inDerivedCtor is false and body Contains SuperCall, throw a SyntaxError exception.
    8. If inClassFieldInitializer is true and ContainsArguments of body is true, throw a SyntaxError exception.
  12. If strictCaller is true, let strictEval be true.
  13. Else, let strictEval be ScriptIsStrict of script.
  14. Let runningContext be the running execution context.
  15. NOTE: If direct is true, runningContext will be the execution context that performed the direct eval. If direct is false, runningContext will be the execution context for the invocation of the eval function.
  16. If direct is true, then
    1. Let lexicalEnv be NewDeclarativeEnvironment(runningContext's LexicalEnvironment).
    2. Let variableEnv be runningContext's VariableEnvironment.
    3. Let privateEnv be runningContext's PrivateEnvironment.
  17. Else,
    1. Let lexicalEnv be NewDeclarativeEnvironment(evalRealm.[[GlobalEnv]]).
    2. Let variableEnv be evalRealm.[[GlobalEnv]].
    3. Let privateEnv be null.
  18. Set privateEnv to NewPrivateEnvironment(privateEnv).
  19. If strictEval is true, set variableEnv to lexicalEnv.
  20. If runningContext is not already suspended, suspend runningContext.
  21. Let evalContext be a new ECMAScript code execution context.
  22. Set evalContext's Function to null.
  23. Set evalContext's Realm to evalRealm.
  24. Set evalContext's ScriptOrModule to runningContext's ScriptOrModule.
  25. Set evalContext's VariableEnvironment to variableEnv.
  26. Set evalContext's LexicalEnvironment to lexicalEnv.
  27. Set evalContext's PrivateEnvironment to privateEnv.
  28. Push evalContext onto the execution context stack; evalContext is now the running execution context.
  29. Let result be Completion(EvalDeclarationInstantiation(body, variableEnv, lexicalEnv, privateEnv, strictEval)).
  30. If result is a normal completion, then
    1. Set result to Completion(Evaluation of body).
  31. If result is a normal completion and result.[[Value]] is empty, then
    1. Set result to NormalCompletion(undefined).
  32. Suspend evalContext and remove it from the execution context stack.
  33. Resume the context that is now on the top of the execution context stack as the running execution context.
  34. Return ? result.
Note

The eval code cannot instantiate variable or function bindings in the variable environment of the calling context that invoked the eval if either the code of the calling context or the eval code is strict mode code. Instead such bindings are instantiated in a new VariableEnvironment that is only accessible to the eval code. Bindings introduced by let, const, or class declarations are always instantiated in a new LexicalEnvironment.

2.7 EvalDeclarationInstantiation ( body, variableEnv, lexicalEnv, privateEnv, strict )

The abstract operation EvalDeclarationInstantiation takes arguments body (a ScriptBody Parse Node), variableEnv (an Environment Record), lexicalEnv (a Declarative Environment Record), privateEnv (a PrivateEnvironment Record or null), and strict (a Boolean) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. Assert: privateEnv is not null.
  2. Let privateBoundIdentifiers be the PrivateBoundIdentifiers of body.
  3. Perform AddPrivateNames(privateEnv, privateBoundIdentifiers).
  4. Let variableNames be the VarDeclaredNames of body.
  5. Let variableDecls be the VarScopedDeclarations of body.
  6. If strict is false, then
    1. If variableEnv is a Global Environment Record, then
      1. For each element name of variableNames, do
        1. If HasLexicalDeclaration(variableEnv, name) is true, throw a SyntaxError exception.
        2. NOTE: eval will not create a global var declaration that would be shadowed by a global lexical declaration.
    2. Let thisEnv be lexicalEnv.
    3. Assert: The following loop will terminate.
    4. Repeat, while thisEnv and variableEnv are not the same Environment Record,
      1. If thisEnv is not an Object Environment Record, then
        1. NOTE: The environment of with statements cannot contain any lexical declaration so it doesn't need to be checked for var/let hoisting conflicts.
        2. For each element name of variableNames, do
          1. If ! thisEnv.HasBinding(name) is true, then
            1. If the host is a web browser or otherwise supports VariableStatements in Catch Blocks, then
              1. If thisEnv is not the Environment Record for a Catch clause, throw a SyntaxError exception.
            2. Else,
              1. Throw a SyntaxError exception.
          2. NOTE: A direct eval will not hoist var declaration over a like-named lexical declaration.
      2. Set thisEnv to thisEnv.[[OuterEnv]].
  7. Let privateIdentifiers be a new empty List.
  8. Let pointer be privateEnv.
  9. Repeat, while pointer is not null,
    1. For each Private Name binding of pointer.[[Names]], do
      1. If privateIdentifiers does not contain binding.[[Description]], append binding.[[Description]] to privateIdentifiers.
    2. Set pointer to pointer.[[OuterPrivateEnvironment]].
  10. If AllPrivateIdentifiersValid of body with argument privateIdentifiers is false, throw a SyntaxError exception.
  11. Let funcsToInitialize be a new empty List.
  12. Let declaredFuncNames be a new empty List.
  13. For each element variableDecl of variableDecls, in reverse List order, do
    1. If variableDecl is not either a VariableDeclaration, a ForBinding, or a BindingIdentifier, then
      1. Assert: variableDecl is either a FunctionDeclaration, a GeneratorDeclaration, an AsyncFunctionDeclaration, or an AsyncGeneratorDeclaration.
      2. NOTE: If there are multiple function declarations for the same name, the last declaration is used.
      3. Let funcName be the sole element of the BoundNames of variableDecl.
      4. If declaredFuncNames does not contain funcName, then
        1. If variableEnv is a Global Environment Record, then
          1. Let funcDefinable be ? CanDeclareGlobalFunction(variableEnv, funcName).
          2. If funcDefinable is false, throw a TypeError exception.
        2. Append funcName to declaredFuncNames.
        3. Insert variableDecl as the first element of funcsToInitialize.
  14. Let declaredVariableNames be a new empty List.
  15. For each element variableDecl of variableDecls, do
    1. If variableDecl is either a VariableDeclaration, a ForBinding, or a BindingIdentifier, then
      1. For each String name of the BoundNames of variableDecl, do
        1. If declaredFuncNames does not contain name, then
          1. If variableEnv is a Global Environment Record, then
            1. Let variableDefinable be ? CanDeclareGlobalVar(variableEnv, name).
            2. If variableDefinable is false, throw a TypeError exception.
          2. If declaredVariableNames does not contain name, then
            1. Append name to declaredVariableNames.
  16. If strict is false and the host is a web browser or otherwise supports Block-Level Function Declarations Web Legacy Compatibility Semantics, then
    1. Let declaredFuncOrVariableNames be the list-concatenation of declaredFuncNames and declaredVariableNames.
    2. For each FunctionDeclaration funcDecl that is directly contained in the StatementList of any Block, CaseClause, or DefaultClause x such that body Contains x is true, do
      1. Let funcName be the StringValue of the BindingIdentifier of funcDecl.
      2. If replacing the FunctionDeclaration funcDecl with a VariableStatement that has funcName as a BindingIdentifier would not produce any Early Errors for body, then
        1. Let bindingExists be false.
        2. Set thisEnv to lexicalEnv.
        3. Assert: The following loop will terminate.
        4. Repeat, while thisEnv is not variableEnv,
          1. If thisEnv is not an Object Environment Record, then
            1. If ! thisEnv.HasBinding(funcName) is true, then
              1. If the host is a web browser or otherwise supports VariableStatements in Catch Blocks, then
                1. If thisEnv is not the Environment Record for a Catch clause, set bindingExists to true.
              2. Else,
                1. Set bindingExists to true.
          2. Set thisEnv to thisEnv.[[OuterEnv]].
        5. If bindingExists is false and variableEnv is a Global Environment Record, then
          1. If HasLexicalDeclaration(variableEnv, funcName) is false, then
            1. Let funcDefinable be ? CanDeclareGlobalVar(variableEnv, funcName).
          2. Else,
            1. Let funcDefinable be false.
        6. Else,
          1. Let funcDefinable be true.
        7. If bindingExists is false and funcDefinable is true, then
          1. If declaredFuncOrVariableNames does not contain funcName, then
            1. If variableEnv is a Global Environment Record, then
              1. Perform ? CreateGlobalVarBinding(variableEnv, funcName, true).
            2. Else,
              1. Set bindingExists to ! variableEnv.HasBinding(funcName).
              2. If bindingExists is false, then
                1. Perform ! variableEnv.CreateMutableBinding(funcName, true).
                2. Perform ! variableEnv.InitializeBinding(funcName, undefined).
            3. Append funcName to declaredFuncOrVariableNames.
          2. When the FunctionDeclaration funcDecl is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 15.2.6:
            1. Let globalEnv be the running execution context's VariableEnvironment.
            2. Let blockEnv be the running execution context's LexicalEnvironment.
            3. Let funcObj be ! blockEnv.GetBindingValue(funcName, false).
            4. Perform ? globalEnv.SetMutableBinding(funcName, funcObj, false).
            5. Return unused.
  17. NOTE: No abnormal terminations occur after this algorithm step unless variableEnv is a Global Environment Record and the global object is a Proxy exotic object.
  18. Let lexicalDecls be the LexicallyScopedDeclarations of body.
  19. For each element lexicalDecl of lexicalDecls, do
    1. NOTE: Lexically declared names are only instantiated here but not initialized.
    2. For each element name of the BoundNames of lexicalDecl, do
      1. If IsConstantDeclaration of lexicalDecl is true, then
        1. Perform ? lexicalEnv.CreateImmutableBinding(name, true).
      2. Else,
        1. Perform ? lexicalEnv.CreateMutableBinding(name, false).
  20. For each Parse Node funcDecl of funcsToInitialize, do
    1. Let funcName be the sole element of the BoundNames of funcDecl.
    2. Let funcObj be InstantiateFunctionObject of funcDecl with arguments lexicalEnv and privateEnv.
    3. If variableEnv is a Global Environment Record, then
      1. Perform ? CreateGlobalFunctionBinding(variableEnv, funcName, funcObj, true).
    4. Else,
      1. Let bindingExists be ! variableEnv.HasBinding(funcName).
      2. If bindingExists is false, then
        1. NOTE: The following invocation cannot return an abrupt completion because of the validation preceding step 17.
        2. Perform ! variableEnv.CreateMutableBinding(funcName, true).
        3. Perform ! variableEnv.InitializeBinding(funcName, funcObj).
      3. Else,
        1. Perform ! variableEnv.SetMutableBinding(funcName, funcObj, false).
  21. For each String variableName of declaredVariableNames, do
    1. If variableEnv is a Global Environment Record, then
      1. Perform ? CreateGlobalVarBinding(variableEnv, variableName, true).
    2. Else,
      1. Let bindingExists be ! variableEnv.HasBinding(variableName).
      2. If bindingExists is false, then
        1. NOTE: The following invocation cannot return an abrupt completion because of the validation preceding step 17.
        2. Perform ! variableEnv.CreateMutableBinding(variableName, true).
        3. Perform ! variableEnv.InitializeBinding(variableName, undefined).
  22. Return unused.

2.8 Blocks

2.8.1 Runtime Semantics: Evaluation

Block : { StatementList }
  1. Let oldEnv be the running execution context's LexicalEnvironment.
  2. Let blockEnv be NewDeclarativeEnvironment(oldEnv).
  3. Let oldPrivateEnv be the running execution context's PrivateEnvironment.
  4. Let privateBoundIdentifiers be the PrivateBoundIdentifiers of StatementList.
  5. Let blockPrivateEnv be NewPrivateEnvironment(oldPrivateEnv).
  6. Perform AddPrivateNames(blockPrivateEnv, privateBoundIdentifiers).
  7. Set the running execution context's PrivateEnvironment to blockPrivateEnv.
  8. Perform BlockDeclarationInstantiation(StatementList, blockEnv).
  9. Set the running execution context's LexicalEnvironment to blockEnv.
  10. Let blockValue be Completion(Evaluation of StatementList).
  11. Set blockValue to Completion(DisposeResources(blockEnv.[[DisposableResourceStack]], blockValue)).
  12. Set the running execution context's PrivateEnvironment to oldPrivateEnv.
  13. Set the running execution context's LexicalEnvironment to oldEnv.
  14. Return ? blockValue.
Note

No matter how control leaves the Block the LexicalEnvironment and PrivateEnvironment are always restored to their former states.

2.9 PrivateEnvironment Records

A PrivateEnvironment Record is a specification mechanism used to track Private Names based upon the lexical nesting structure of ClassDeclarations and ClassExpressionsscopes in ECMAScript code. They are similar to, but distinct from, Environment Records. Each PrivateEnvironment Record is associated with a ClassDeclaration or ClassExpressionsome syntactic construct such as a ClassDeclaration or FunctionBody. Each time such a classcode is evaluated, a new PrivateEnvironment Record is created to record the Private Names declared by that classthat code.

Each PrivateEnvironment Record has the fields defined in Table 1.

Table 1: PrivateEnvironment Record Fields
Field Name Value Type Meaning
[[OuterPrivateEnvironment]] a PrivateEnvironment Record or null The PrivateEnvironment Record of the nearest containing class. null if the class with which this PrivateEnvironment Record is associated is not contained in any other classprivate scope. null if the private scope with which this PrivateEnvironment Record is associated is not contained in any other private scope.
[[Names]] a List of Private Names The Private Names declared by this classprivate scope.

2.9.1 PrivateEnvironment Record Operations

The following abstract operations are used in this specification to operate upon PrivateEnvironment Records:

2.9.1.1 AddPrivateNames ( privateEnv, descriptions )

The abstract operation AddPrivateNames takes arguments privateEnv (a PrivateEnvironment Record) and descriptions (a List of Strings) and returns unused. It performs the following steps when called:

  1. For each String description of descriptions, do
    1. Let name be a new Private Name whose [[Description]] is description.
    2. Append name to privateEnv.[[Names]].
  2. Return unused.

3 Modified Syntax-Directed Operations

3.1 Static Semantics: LexicallyDeclaredNames

The syntax-directed operation LexicallyDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

StatementListItem : PrivateDeclaration
  1. Return a new empty List.

3.2 Static Semantics: LexicallyScopedDeclarations

The syntax-directed operation LexicallyScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

StatementListItem : PrivateDeclaration
  1. Return a new empty List.

3.3 Static Semantics: VarDeclaredNames

The syntax-directed operation VarDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

StatementListItem : PrivateDeclaration
  1. Return a new empty List.

3.4 Static Semantics: VarScopedDeclarations

The syntax-directed operation VarScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

StatementListItem : PrivateDeclaration
  1. Return a new empty List.

3.5 Static Semantics: TopLevelLexicallyDeclaredNames

The syntax-directed operation TopLevelLexicallyDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

StatementListItem : PrivateDeclaration
  1. Return a new empty List.

3.6 Static Semantics: TopLevelLexicallyScopedDeclarations

The syntax-directed operation TopLevelLexicallyScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

StatementListItem : PrivateDeclaration
  1. Return a new empty List.

3.7 Static Semantics: TopLevelVarDeclaredNames

The syntax-directed operation TopLevelVarDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

StatementListItem : PrivateDeclaration
  1. Return a new empty List.

3.8 Static Semantics: TopLevelVarScopedDeclarations

The syntax-directed operation TopLevelVarScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

StatementListItem : PrivateDeclaration
  1. Return a new empty List.

3.9 Static Semantics: ContainsUsing

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

StatementListItem : PrivateDeclaration
  1. Return false.

3.10 Static Semantics: ContainsDuplicateLabels

The syntax-directed operation ContainsDuplicateLabels takes argument labelSet (a List of Strings) and returns a Boolean. It is defined piecewise over the following productions:

StatementListItem : PrivateDeclaration
  1. Return false.

3.11 Static Semantics: ContainsUndefinedBreakTarget

The syntax-directed operation ContainsUndefinedBreakTarget takes argument labelSet (a List of Strings) and returns a Boolean. It is defined piecewise over the following productions:

StatementListItem : PrivateDeclaration
  1. Return false.

3.12 Static Semantics: ContainsUndefinedContinueTarget

The syntax-directed operation ContainsUndefinedContinueTarget takes arguments iterationSet (a List of Strings) and labelSet (a List of Strings) and returns a Boolean. It is defined piecewise over the following productions:

StatementListItem : PrivateDeclaration
  1. Return false.

3.13 Static Semantics: HasCallInTailPosition

The syntax-directed operation HasCallInTailPosition takes argument call (a CallExpression Parse Node, a MemberExpression Parse Node, or an OptionalChain Parse Node) and returns a Boolean. It is defined piecewise over the following productions:

StatementListItem : PrivateDeclaration
  1. Return false.

Copyright & Software License

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.