Bug 258683
Summary: | Function defined within a `with` statement, but called from outside it - cannot access variables exposed by `with` | ||
---|---|---|---|
Product: | WebKit | Reporter: | Joe <niseg98160> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Normal | CC: | ashvayka, mark.lam, webkit-bug-importer, ysuzuki |
Priority: | P2 | Keywords: | InRadar |
Version: | Safari 17 | ||
Hardware: | All | ||
OS: | All |
Joe
`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
<rdar://problem/111857202>
Alexey Shvayka
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 ***