<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>258683</bug_id>
          
          <creation_ts>2023-06-29 10:29:09 -0700</creation_ts>
          <short_desc>Function defined within a `with` statement, but called from outside it - cannot access variables exposed by `with`</short_desc>
          <delta_ts>2023-09-24 13:59:13 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>Safari 17</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>163209</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Joe">niseg98160</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ashvayka</cc>
    
    <cc>mark.lam</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1964281</commentid>
    <comment_count>0</comment_count>
    <who name="Joe">niseg98160</who>
    <bug_when>2023-06-29 10:29:09 -0700</bug_when>
    <thetext>`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 &quot;Can&apos;t find variable: foo&quot; in Safari:

```js
let obj = {foo:&quot;bar&quot;};
with(obj) {
  function test() {
    console.log(foo);
  }
}
test();
```

Perchance.org, for example, uses `with` as part of its DSL, and so a subset of &apos;generators&apos; are broken for Safari users.

Possibly related: https://bugs.webkit.org/show_bug.cgi?id=231166</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1965387</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-07-06 10:30:21 -0700</bug_when>
    <thetext>&lt;rdar://problem/111857202&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1979665</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Shvayka">ashvayka</who>
    <bug_when>2023-09-24 13:59:13 -0700</bug_when>
    <thetext>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 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>