<?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>182414</bug_id>
          
          <creation_ts>2018-02-01 17:02:21 -0800</creation_ts>
          <short_desc>Async arrow function with var declaration has incorrect shadowing</short_desc>
          <delta_ts>2023-10-15 11:58:56 -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>223533</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>lharker</cc>
    
    <cc>mark.lam</cc>
    
    <cc>matsaa</cc>
    
    <cc>theodorejb</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1395706</commentid>
    <comment_count>0</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2018-02-01 17:02:21 -0800</bug_when>
    <thetext>The following code, run in the shell, should print &quot;7&quot;, but prints &quot;undefined&quot;:

  (async (v) =&gt; { print(v); var v; })(7)

Without &quot;async&quot;, this gets the right answer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395940</commentid>
    <comment_count>1</comment_count>
    <who name="GSkachkov">gskachkov</who>
    <bug_when>2018-02-02 12:01:29 -0800</bug_when>
    <thetext>Hmm, the same for common async function
```
(async function (v) { print(v); var v; })(7);
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395942</commentid>
    <comment_count>2</comment_count>
    <who name="GSkachkov">gskachkov</who>
    <bug_when>2018-02-02 12:04:19 -0800</bug_when>
    <thetext>Yeah and the same for generator and async generators</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395949</commentid>
    <comment_count>3</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-02-02 12:21:24 -0800</bug_when>
    <thetext>Hm, shoud it print 7? Why doesn’t “var” hide?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395964</commentid>
    <comment_count>4</comment_count>
    <who name="GSkachkov">gskachkov</who>
    <bug_when>2018-02-02 12:59:07 -0800</bug_when>
    <thetext>(In reply to Yusuke Suzuki from comment #3)
&gt; Hm, shoud it print 7? Why doesn’t “var” hide?

I cann&apos;t find this rule in current spec but it was in ES5, there is a exist old tests:
```
https://github.com/tc39/test262/blob/master/test/language/function-code/S10.2.1_A5.2_T1.js
https://github.com/tc39/test262/blob/master/test/language/function-code/S10.2.1_A5.1_T2.js
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395972</commentid>
    <comment_count>5</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2018-02-02 13:15:06 -0800</bug_when>
    <thetext>See step 27 of https://tc39.github.io/ecma262/#sec-functiondeclarationinstantiation. Basically, if a var-declared name has the same name as a parameter (and there aren&apos;t any parameter expressions, i.e., default parameter values or destructuring), the var declaration is ignored.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1760053</commentid>
    <comment_count>6</comment_count>
    <who name="Mats Åhlberg">matsaa</who>
    <bug_when>2021-05-14 04:34:21 -0700</bug_when>
    <thetext>When running code through uglify-js it generates this type of code which breaks.
 var b=async (t,a,r)=&gt; {
 console.log(a);
   var a = a;
   console.log(t);
   console.log(a);
   console.log(r);
   return { t, a, r };
  };
  b(1, 2, 3);

replacing the var a = 1; with a=a works.
the first console log says undefined when the var is left.

the code works in firefox and chrome. 

so is this a bug in webkit or the other browsers?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1971200</commentid>
    <comment_count>7</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-08-14 18:46:59 -0700</bug_when>
    <thetext>&lt;rdar://problem/113883888&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1985200</commentid>
    <comment_count>8</comment_count>
    <who name="Alexey Shvayka">ashvayka</who>
    <bug_when>2023-10-15 11:58:56 -0700</bug_when>
    <thetext>

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

    </bug>

</bugzilla>