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

Support ES6 block scoping #18

Open
ngocdaothanh opened this issue Jun 23, 2018 · 5 comments
Open

Support ES6 block scoping #18

ngocdaothanh opened this issue Jun 23, 2018 · 5 comments

Comments

@ngocdaothanh
Copy link

(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.

@basicer
Copy link
Member

basicer commented Jun 23, 2018

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.

@basicer
Copy link
Member

basicer commented Jul 5, 2018

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

@ngocdaothanh
Copy link
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]

@ngocdaothanh
Copy link
Author

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

@basicer
Copy link
Member

basicer commented Feb 7, 2019

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants