<?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>179698</bug_id>
          
          <creation_ts>2017-11-14 15:18:19 -0800</creation_ts>
          <short_desc>Sloppy mode function declaration in block unable to access lexical variable</short_desc>
          <delta_ts>2023-09-21 23:47:20 -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>WebKit Local Build</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 name="Adam Klein">adamk</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ashvayka</cc>
    
    <cc>gskachkov</cc>
    
    <cc>mark.lam</cc>
    
    <cc>saam</cc>
    
    <cc>syg</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1371597</commentid>
    <comment_count>0</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2017-11-14 15:18:19 -0800</bug_when>
    <thetext>Test case:

{
  let a = 42;
  function f() { return a }
  print(f())
}

This throws &quot;ReferenceError: Can&apos;t find variable: a&quot;. If I run this in strict mode, it works as expected (printing 42).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1372908</commentid>
    <comment_count>1</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2017-11-16 17:15:31 -0800</bug_when>
    <thetext>(In reply to Adam Klein from comment #0)
&gt; Test case:
&gt; 
&gt; {
&gt;   let a = 42;
&gt;   function f() { return a }
&gt;   print(f())
&gt; }
&gt; 
&gt; This throws &quot;ReferenceError: Can&apos;t find variable: a&quot;. If I run this in
&gt; strict mode, it works as expected (printing 42).

We don&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1959915</commentid>
    <comment_count>2</comment_count>
    <who name="Shu-yu Guo">syg</who>
    <bug_when>2023-06-05 10:35:49 -0700</bug_when>
    <thetext>Friendly ping. It&apos;s been a while, would be good to get this fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1960299</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-06-07 07:48:26 -0700</bug_when>
    <thetext>&lt;rdar://problem/110394639&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1979285</commentid>
    <comment_count>4</comment_count>
    <who name="Alexey Shvayka">ashvayka</who>
    <bug_when>2023-09-21 23:47:20 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 163209 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>