Bug 227281
Summary: | function within a block statement has broken scope for const/let | ||
---|---|---|---|
Product: | WebKit | Reporter: | Samuel <samuel.elg> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Normal | CC: | fpizlo, saam, ysuzuki |
Priority: | P2 | ||
Version: | Safari 14 | ||
Hardware: | Mac (Intel) | ||
OS: | macOS 11 |
Samuel
When a function within a block scope tries to access a variable declared with `const`/`let` on the wrapping scope a RefferenceError is thrown.
Reproducible example:
```
{
const a = true; // also happens with "let" declarations.
function main() {
console.log(a);
}
main();
}
```
Accessing `a` on the 4th line throws an error: "ReferenceError: Can't find variable: a".
The expected behavior would be for the "a" variable to be in the scope of the function "main".
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Yusuke Suzuki
This is dupe of bug 163209.
*** This bug has been marked as a duplicate of bug 163209 ***