Skip to content

Recursive let/const references should error #2188

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

Closed
JsonFreeman opened this issue Mar 2, 2015 · 0 comments · Fixed by #2309
Closed

Recursive let/const references should error #2188

JsonFreeman opened this issue Mar 2, 2015 · 0 comments · Fixed by #2309
Labels
Bug A bug in TypeScript ES6 Relates to the ES6 Spec Fixed A PR has been merged for this issue

Comments

@JsonFreeman
Copy link
Contributor

The constructs:

let v = v;
const c = c;

should error because they are uses before definition. Indeed IE gives this error.

This also applies to:

for (let v = v; ; ) { }
for (let v in v) { }
for (let v of v) { }

For the latter two in particular, look at section 13.6.4.12 in the ES6 spec:

  1. Let oldEnv be the running execution context’s LexicalEnvironment.

  2. If TDZnames is not an empty List, then

    a. Assert: TDZnames has no duplicate entries.
    b. Let TDZ be NewDeclarativeEnvironment(oldEnv).
    c. For each string name in TDZnames, do

      i. Let status be TDZ.CreateMutableBinding(name, false).
      ii. Assert: status is never an abrupt completion.
    

    d. Set the running execution context’s LexicalEnvironment to TDZ.

  3. Let exprRef be the result of evaluating the production that is expr.

  4. Set the running execution context’s LexicalEnvironment to oldEnv.

@JsonFreeman JsonFreeman added Bug A bug in TypeScript ES6 Relates to the ES6 Spec labels Mar 2, 2015
@mhegazy mhegazy added this to the TypeScript 1.5 milestone Mar 11, 2015
@vladima vladima added the Fixed A PR has been merged for this issue label Mar 12, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript ES6 Relates to the ES6 Spec Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants