Skip to content

Support ES6 block scoping #18

Open

Description

@ngocdaothanh

(Related to #15 and #16)

Is it easy to add support for ES6 block scoping for let and const?

It's somewhat meaningless (and even confusing) to have let and const but no block scoping for them, because it's the main difference between them and var.

Activity

  1. basicer commented on Jun 23, 2018

    @basicer
    Contributor

    It's not so hard.

    You would need to expand the Scope class to track both the block scope, and the function scope. This gets a little tricky when things like declaring a let inside a for loop deceleration is considered.

    It's on my TODO list for sure.

  2. basicer commented on Jul 5, 2018

    @basicer
    Contributor

    I added some support for this in 268909e, but it needs some testing. Let me know what you think.

  3. ngocdaothanh commented on Jul 5, 2018

    @ngocdaothanh
    Author

    Thanks for working on this feature!

    I've tried the code at #16 again, but it still doesn't work as expected.

    To make it work as expected, I still need to change this line:

    const char = string[i]
    

    to:

    let char = string[i]
    
  4. ngocdaothanh commented on Feb 7, 2019

    @ngocdaothanh
    Author

    Hi, is PR #20 "Closure fixes" for fixing this issue?

  5. basicer commented on Feb 7, 2019

    @basicer
    Contributor

    It improves the situation but does not fix it entirely.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions