Skip to content

[CP] Fix Dart2JS crash on record pattern outside function body #53449

Description

@biggs0125

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

Metadata

Metadata

Labels

area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.cherry-pick-approvedLabel for approved cherrypick requestcherry-pick-reviewIssue that need cherry pick triage to approvemerge-to-stable

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions