Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CP] Fix Dart2JS type inference for record accesses on invalid indices. #52443

Closed
biggs0125 opened this issue May 18, 2023 · 2 comments
Closed
Assignees
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-merged Cherry-pick has been merged to the stable or beta branch. cherry-pick-review Issue that need cherry pick triage to approve merge-to-stable

Comments

@biggs0125
Copy link

Commit(s) to merge

327a680

Target

stable

Prepared changelist for beta/stable

https://dart-review.googlesource.com/c/sdk/+/304420

Issue Description

#52438

Dart2JS type inference crashes when a record field is accessed but the receiver type does not contain that field.

Users cannot manually generate code like that but code generated by switches can. Specifically when a record is demoted to dynamic/Object and then cased on in a switch with non-matching cases. The generated code from such a switch can contain record accesses that cause these crashes.

What is the fix

The fix is for each record access to check that the type of the receiver supports the selector being used.

Why cherry-pick

This causes crashes in Dart2JS on fairly trivial code. Multiple developers have discovered this bug.

Risk

low

Issue link(s)

#52438

Extra Info

No response

@biggs0125 biggs0125 added the cherry-pick-review Issue that need cherry pick triage to approve label May 18, 2023
@sigmundch
Copy link
Member

I'm very much in support of this cherry-pick - I think this has potential to surface often and the fix is very low risk.

@itsjustkevin itsjustkevin added merge-to-stable 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 labels May 19, 2023
@sigmundch sigmundch reopened this May 19, 2023
@sigmundch sigmundch added the cherry-pick-merged Cherry-pick has been merged to the stable or beta branch. label May 19, 2023
@sigmundch
Copy link
Member

(reopening so that the issue is seen by engprod when they create the release candidate, they can close when they confirm it was shipped in 3.0.2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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-merged Cherry-pick has been merged to the stable or beta branch. cherry-pick-review Issue that need cherry pick triage to approve merge-to-stable
Projects
None yet
Development

No branches or pull requests

7 participants