Bug 271240

Summary: Parameter of async function is undefined if it reassigned later
Product: WebKit Reporter: csongor.szilagyi
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: ahmad.saleem792, bogdanb, karlcow, mark.lam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 17   
Hardware: Mac (Apple Silicon)   
OS: macOS 14   
Attachments:
Description Flags
A short html snippet to reproduce the issue none

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!