hermes
hermes copied to clipboard
Bug in scoped function promotion (non-strict mode)
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?
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.
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 it's just being used for testing this behaviour