<?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>231166</bug_id>
          
          <creation_ts>2021-10-04 04:28:34 -0700</creation_ts>
          <short_desc>&quot;Can&apos;t find variable&quot; that&apos;s let-declared within `with` statement when executing function that&apos;s declared within same `with` statement</short_desc>
          <delta_ts>2023-09-24 13:59:23 -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 15</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</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>yanahij531</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ashvayka</cc>
    
    <cc>fpizlo</cc>
    
    <cc>kevin_neal</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1800027</commentid>
    <comment_count>0</comment_count>
    <who name="">yanahij531</who>
    <bug_when>2021-10-04 04:28:34 -0700</bug_when>
    <thetext>In Firefox and Chrome the following code works fine, but Safari throws an error saying that the variable `a` cannot be found.

```
with({}) {
  let a = 1;
  function foo() {
    console.log(a);
  }
  foo();
}
```

https://jsbin.com/hiwihiyaxi/edit?html,console</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1800619</commentid>
    <comment_count>1</comment_count>
    <who name="Kevin Neal">kevin_neal</who>
    <bug_when>2021-10-05 10:13:51 -0700</bug_when>
    <thetext>Thanks for filing. I was able to reproduce the bug in Safari. The appropriate engineers have been notified.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1800621</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-10-05 10:14:10 -0700</bug_when>
    <thetext>&lt;rdar://problem/83892140&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1979667</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Shvayka">ashvayka</who>
    <bug_when>2023-09-24 13:59:23 -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>