Bug 179698
Summary: | Sloppy mode function declaration in block unable to access lexical variable | ||
---|---|---|---|
Product: | WebKit | Reporter: | Adam Klein <adamk> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Normal | CC: | ashvayka, gskachkov, mark.lam, saam, syg, webkit-bug-importer, ysuzuki |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Local Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Adam Klein
Test case:
{
let a = 42;
function f() { return a }
print(f())
}
This throws "ReferenceError: Can't find variable: a". If I run this in strict mode, it works as expected (printing 42).
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Saam Barati
(In reply to Adam Klein from comment #0)
> Test case:
>
> {
> let a = 42;
> function f() { return a }
> print(f())
> }
>
> This throws "ReferenceError: Can't find variable: a". If I run this in
> strict mode, it works as expected (printing 42).
We don't support this in global scope. We do support it inside functions and I believe eval. We still need to implement it for the global scope.
e.g, replace outer {} with function (and maybe eval) and it works.
Shu-yu Guo
Friendly ping. It's been a while, would be good to get this fixed.
Radar WebKit Bug Importer
<rdar://problem/110394639>
Alexey Shvayka
*** This bug has been marked as a duplicate of bug 163209 ***