Skip to content
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

Avoid adding unnecessary closure for block scoping #5246

Merged
merged 1 commit into from Feb 13, 2017

Commits on Feb 11, 2017

  1. Avoid adding unnecessary closure for block scoping

    When you write
    
    ```
    for (const x of l) {
      setTimeout(() => x);
    }
    ```
    
    we need to add a closure because the variable is meant to be block-scoped and recreated each time the block runs. We do this.
    
    However, we also add the closure when no loop is present. This isn't necessary, because if no loop is present then each piece of code runs at most once. I changed the transform to only add a closure if a variable is referenced from within a loop.
    sophiebits committed Feb 11, 2017
    Copy the full SHA
    7f9af76 View commit details
    Browse the repository at this point in the history