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

Bug in scoped function promotion (non-strict mode) #1455

Open
trossimel-sc opened this issue Jul 9, 2024 · 3 comments
Open

Bug in scoped function promotion (non-strict mode) #1455

trossimel-sc opened this issue Jul 9, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@trossimel-sc
Copy link

trossimel-sc commented Jul 9, 2024

Bug Description

I noticed a different behaviour between Hermes and other JS engines (tried with QuickJS, JSC and V8) when running the following script

if(true) {
    function test(a) {
        if(a == "a") {
            test("b");
            return;
        }
        print ('Error');
    }

    callback1 = test;
}
if(true) {

    function test(a) {
        if(a == "a") {
            test("b");
            return;
        }
        print ('Error1');
    }

    callback2 = test;
}

callback1("a");
callback2("a");

The Expected Behavior

In Hermes the output is Error1; Error1, while in QuickJS the output is Error; Error1.
Is this behaviour expected?

@trossimel-sc trossimel-sc added the bug Something isn't working label Jul 9, 2024
@avp
Copy link
Contributor

avp commented Jul 9, 2024

Thanks for the report. Looks like we're resolving the test() call in the first test() function incorrectly. We'll figure out how to solve this.

@tmikov
Copy link
Contributor

tmikov commented Jul 11, 2024

I hope this isn't code that is actually used anywhere. It isn't even valid in strict mode, which is hopefully the default everywhere.

@tmikov tmikov changed the title Different behaviour between Hermes and other JS engines (V8/JSC/QuickJS) Bug in scoped function promotion (non-strict mode) Jul 11, 2024
@trossimel-sc
Copy link
Author

@tmikov it's just being used for testing this behaviour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants