[CP] Fix Dart2JS crash on record pattern outside function body #53449
Labels
area-web
Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop.
cherry-pick-approved
Label for approved cherrypick request
cherry-pick-review
Issue that need cherry pick triage to approve
merge-to-stable
Commit(s) to merge
https://dart-review.googlesource.com/c/sdk/+/323020
Target
stable
Prepared changelist for beta/stable
https://dart-review.googlesource.com/c/sdk/+/324600
Issue Description
Dart2JS was crashing when a record pattern was used outside the scope of a function body. This could happen in constructor initializers or field initializers.
The crash was due to the CFE's lowering of these patterns to statements containing late local variables. Dart2JS's late lowering assumed that late locals would always be within function bodies and this was true prior to the introduction of the CFE's record pattern lowering.
What is the fix
The fix is to allow for late locals within more contexts. This just means setting up a scope context for them around field initializers and around constuctors.
Why cherry-pick
Dart2JS crashes on valid inputs. The fix is simple enough to be low risk.
Risk
low
Issue link(s)
#53358
Extra Info
No response
The text was updated successfully, but these errors were encountered: