archives

« Bugzilla Issues Index

#4377 — Remove environment parameters from GlobalDeclarationInstantiation/EvalDeclarationInstantiation


{Global, Eval}DeclarationInstantiation access the current variable/lexical environments through explicit parameters.
Both abstract operations should instead use the execution context to retrieve the environment state. Otherwise it's
possible to pass or rather it gives the wrong impression it's valid to pass other environments to global/eval declaration
instantiation than the current environments.
FunctionDeclarationInstantiation already retrieves the current lexical environment through the execution context.


Proposed changes:

15.1.7 Runtime Semantics: ScriptEvaluation
10. Let result be GlobalDeclarationInstantiation(ScriptBody).

15.1.8 Runtime Semantics: GlobalDeclarationInstantiation(script)
1. Let env be the running execution context’s LexicalEnvironment.
2. Let envRec be env’s EnvironmentRecord.
3. Assert: envRec is a global Environment Record.


18.2.1.1 Runtime Semantics: PerformEval(x, evalRealm, strictCaller, direct)
18. Let result be EvalDeclarationInstantiation(body, strictEval).

18.2.1.2 Runtime Semantics: EvalDeclarationInstantiation(body, strict)
1. Let varEnv be the running execution context’s VariableEnvironment.
2. Let varEnvRec be varEnv’s EnvironmentRecord.
3. Let lexEnv be the running execution context’s LexicalEnvironment.
4. Let lexEnvRec be lexEnv’s EnvironmentRecord.
5. Assert: lexEnvRec is a declarative Environment Record.