New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contradiction concerning Execution Contexts? #980

Closed
tmerr opened this Issue Aug 21, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@tmerr
Contributor

tmerr commented Aug 21, 2017

Section 8.3 Execution Contexts claims:

The LexicalEnvironment and VariableEnvironment components of an execution context are always Lexical Environments. When an execution context is created its LexicalEnvironment and VariableEnvironment components initially have the same value.

Is this always the case?

18.2.1.1 Runtime Semantics: PerformEval
...

11. Let ctx be the running execution context.
12. NOTE: If direct is true, ctx will be the execution context that performed the direct eval. If direct is false, ctx will be the execution context for the invocation of the eval function.
13. If direct is true, then
    a. Let lexEnv be NewDeclarativeEnvironment(ctx's LexicalEnvironment).
    b. Let varEnv be ctx's VariableEnvironment.
14. Else,
    a. Let lexEnv be NewDeclarativeEnvironment(evalRealm.[[GlobalEnv]]).
    b. Let varEnv be evalRealm.[[GlobalEnv]].
15. If strictEval is true, set varEnv to lexEnv.
...
17. Let evalCxt be a new ECMAScript code execution context.
...
21. Set the evalCxt's VariableEnvironment to varEnv.
22. Set the evalCxt's LexicalEnvironment to lexEnv.
23. Push evalCxt on to the execution context stack; evalCxt is now the running execution context.
...

With the program var x = 3; eval("let y = 4");, direct would be true, and strict would be false. So upon entering the eval we would create an Execution Context with an empty LexicalEnvironmnent (aside from its outer), and reuse the old VariableEnvironment. Doesn't this contradict the claim that "When an execution context is created its LexicalEnvironment and VariableEnvironment components initially have the same value"?

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Aug 29, 2017

Member

Yeah I think that statement is misleading. I'll probably just remove it.

Member

bterlson commented Aug 29, 2017

Yeah I think that statement is misleading. I'll probably just remove it.

@tmerr

This comment has been minimized.

Show comment
Hide comment
@tmerr

tmerr Aug 30, 2017

Contributor

As far as I can tell the statement was accurate back in 5.1 then broke in 6.0. Removal would be great! 👍

Contributor

tmerr commented Aug 30, 2017

As far as I can tell the statement was accurate back in 5.1 then broke in 6.0. Removal would be great! 👍

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Aug 30, 2017

Member

@tmerr want to send a PR?

Member

bterlson commented Aug 30, 2017

@tmerr want to send a PR?

tmerr added a commit to tmerr/ecma262 that referenced this issue Aug 30, 2017

Editorial: Remove out-of-date sentence about execution contexts
This sentence has been around for some time and is no longer accurate.
PerformEval can create an execution context with initially different
LexicalEnvironment and VariableEnvironment components.

Closes tc39#980.

bterlson added a commit that referenced this issue Aug 31, 2017

Editorial: Remove out-of-date sentence about execution contexts (#986)
This sentence has been around for some time and is no longer accurate.
PerformEval can create an execution context with initially different
LexicalEnvironment and VariableEnvironment components.

Closes #980.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment