Bug 271240 - Parameter of async function is undefined if it reassigned later
Summary: Parameter of async function is undefined if it reassigned later
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari 17
Hardware: Mac (Apple Silicon) macOS 14
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2024-03-19 07:49 PDT by csongor.szilagyi
Modified: 2024-04-03 04:16 PDT (History)
5 users (show)

See Also:


Attachments
A short html snippet to reproduce the issue (289 bytes, text/html)
2024-03-19 07:49 PDT, csongor.szilagyi
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description csongor.szilagyi 2024-03-19 07:49:54 PDT
Created attachment 470434 [details]
A short html snippet to reproduce the issue

Consider the following async function:


  async function test_1(a) {
    console.log(a)
    var a = a === 0 ? 1 : 2;
    console.log(a)
  }
  
  test_1(1);

## Expected output: 1 2
## Actual output: undefined 2

Additional note: if the parameter is not reassigned in the function, the console.log prints the correct value. 

Expected output can be tested in Chrome, Firefox, Edge
Comment 1 Karl Dubost 2024-03-21 19:49:42 PDT
I get the same output in the 3 browsers
[Log] 0 (attachment.cgi, line 6)
[Log] 1 (attachment.cgi, line 8)
[Log] 0 (attachment.cgi, line 11)

With 

Safari Technology Preview  190           19619.1.5.5.2
Firefox Nightly            125.0a1       12524.3.12
Google Chrome Canary       125.0.6371.0  6371.0
Comment 2 Radar WebKit Bug Importer 2024-03-26 07:50:13 PDT
<rdar://problem/125416378>
Comment 3 csongor.szilagyi 2024-03-31 04:41:53 PDT
I can confirm that it works in Technology Preview 190. Looking forward to be included in the main build too.
Comment 4 Karl Dubost 2024-04-01 04:21:43 PDT
Thanks!