WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 163209
258683
Function defined within a `with` statement, but called from outside it - cannot access variables exposed by `with`
https://bugs.webkit.org/show_bug.cgi?id=258683
Summary
Function defined within a `with` statement, but called from outside it - cann...
Joe
Reported
2023-06-29 10:29:09 PDT
`with` is deprecated, but there is still a bunch of legacy code that uses it. This code works fine in Firefox and Chrome but throws "Can't find variable: foo" in Safari: ```js let obj = {foo:"bar"}; with(obj) { function test() { console.log(foo); } } test(); ``` Perchance.org, for example, uses `with` as part of its DSL, and so a subset of 'generators' are broken for Safari users. Possibly related:
https://bugs.webkit.org/show_bug.cgi?id=231166
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2023-07-06 10:30:21 PDT
<
rdar://problem/111857202
>
Alexey Shvayka
Comment 2
2023-09-24 13:59:13 PDT
Thank you for reporting! This bug arises because block-level function declarations in global code, which are subject to currently unimplemented legacy Annex B hoisting, always receive top-level scope instead of lexical one.
https://bugs.webkit.org/show_bug.cgi?id=163209
implements Annex B function hoisting for global code, fixing this issue. *** 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.
Top of Page
Format For Printing
XML
Clone This Bug