chakra-core / chakra-core/ChakraCore

Global var set before evaluating function declaration in non-strict block

Open
#5,340 8 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.