Bug in scoped function promotion (non-strict mode)
- Dominant language
- JavaScript
- Stars
- 11.3k
- Forks
- 859
- Avg merge
- 1h 30m
- Merged PRs (30d)
- 3
Description
## 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?
Contributor guide
Research direction
Start by running the supplied script in Hermes and the comparison engines to confirm the differing outputs. Then trace how Hermes handles function declarations inside block scopes in non-strict mode and locate related regression tests. Done means establishing the expected behavior and adding or updating coverage so the result is consistent with the agreed semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100