RESOLVED DUPLICATE of bug 163209 179698
Sloppy mode function declaration in block unable to access lexical variable
https://bugs.webkit.org/show_bug.cgi?id=179698
Summary Sloppy mode function declaration in block unable to access lexical variable
Adam Klein
Reported 2017-11-14 15:18:19 PST
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
Saam Barati
Comment 1 2017-11-16 17:15:31 PST
(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
Comment 2 2023-06-05 10:35:49 PDT
Friendly ping. It's been a while, would be good to get this fixed.
Radar WebKit Bug Importer
Comment 3 2023-06-07 07:48:26 PDT
Alexey Shvayka
Comment 4 2023-09-21 23:47:20 PDT
*** This bug has been marked as a duplicate of bug 163209 ***
Note You need to log in before you can comment on or make changes to this bug.