chakra-core / chakra-core/ChakraCore
Global var set before evaluating function declaration in non-strict block
Open
Bug
Compatibility
Severity: 3
- Dominant language
- JavaScript
- Stars
- 9.3k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
For the following test case:
```js
function getF() { return f; }
{
if (getF() === f) {
print('Global var set before evaluating function declaration');
}
function f() { return "bar"; }
}
```
I see:
```
#### ch
Global var set before evaluating function declaration
#### sm
#### v8
#### jsc
Global var set before evaluating function declaration
```
According to [B3.3.2](https://tc39.github.io/ecma262/#sec-web-compat-globaldeclarationinstantiation), the global "var" binding should be initialized to undefined, and only set to the block-level value of f when the function declaration is evaluated.
Contributor guide
Assessment
This issue has not been assessed yet.