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

Variable Scope Problem #679

Closed
YiWen-y opened this issue Feb 22, 2022 · 1 comment
Closed

Variable Scope Problem #679

YiWen-y opened this issue Feb 22, 2022 · 1 comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request

Comments

@YiWen-y
Copy link

YiWen-y commented Feb 22, 2022

Version

0.10.0

Test case
var foo = function() {
    var x = 3;
    if (x > 0) {
        let x = 7;
        print(x);
    }
    print(x);
};
foo();
Execution steps
.jsvu/hermes Testcase.js
Output
7 7
Expected behavior
7 3
Description

The correct output of the test case should be 7 3 while hermes outputs 7 7. I think hermes fails to deal with the scope of the global and local variable x, where hermes may treat the local variable x at line 4 as the global variable, leading to output 7 at line 7.

@YiWen-y YiWen-y added the bug Something isn't working label Feb 22, 2022
@neildhar
Copy link
Contributor

Hi @YiWen-y, Hermes does not support block scoping, and we instead rely on Babel transforms to lower cases like these into something that can run in Hermes. Please see #575 for more details.

@neildhar neildhar added duplicate This issue or pull request already exists enhancement New feature or request and removed bug Something isn't working labels Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants