<?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>226335</bug_id>
          
          <creation_ts>2021-05-27 09:10:33 -0700</creation_ts>
          <short_desc>Redeclaring an argument of the async function makes it `undefined`</short_desc>
          <delta_ts>2023-10-15 11:59:27 -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 14</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</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>kotkov</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ashvayka</cc>
    
    <cc>fpizlo</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1764346</commentid>
    <comment_count>0</comment_count>
    <who name="">kotkov</who>
    <bug_when>2021-05-27 09:10:33 -0700</bug_when>
    <thetext>Consider the following JavaScript code example:

function foo(x) {
    console.log(x);
    var x = 2;
    console.log(x);
}
foo(1);

async function bar(x) {
    console.log(x);
    var x = 2;
    console.log(x);
}
bar(1);

Running this example in stable Chromium or Firefox versions produces the following expected result:

1
2
1
2

Running this example in Safari produces the following *unexpected* result:

1
2
undefined
2

This issue reproduces in Safari 12.x, 13.x, 14.x on macOS and iOS.
This issue reproduces in Safari 14.1.1 on macOS 11.4.

Apparently, redeclaring the argument `x` of an async function with `var x` in the function&apos;s body causes the initial argument to lose its value and become `undefined`. As shown in the above example, this behavior is specific to async functions and doesn&apos;t reproduce in non-async functions.

Redeclaring function arguments in this way is a common technique used by code minifiers such as uglify-js, as that sometimes allows reusing shorter variable names.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1766412</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-06-03 09:11:19 -0700</bug_when>
    <thetext>&lt;rdar://problem/78818618&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1985202</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Shvayka">ashvayka</who>
    <bug_when>2023-10-15 11:59:27 -0700</bug_when>
    <thetext>

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

    </bug>

</bugzilla>