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

[compiler] repro for dep merging edge case (non-hir) #31035

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

mofeiZ
Copy link
Contributor

@mofeiZ mofeiZ commented Sep 23, 2024

Stack from ghstack (oldest at bottom):

Found when writing #31037, summary copied from comments:

This is an extreme edge case and not code we'd expect any reasonable developer to write. In most cases e.g. (a?.b != null ? a.b : DEFAULT), we do want to take a dependency on a?.b.

I found this trying to come up with edge cases that break the current dependency + CFG merging logic. I think it makes sense to error on the side of correctness. After all, we still take a as a dependency if users write a != null ? a.b : DEFAULT, and the same fix (understanding the <hoistable> != null test expression) works for both. Can be convinced otherwise though!

[ghstack-poisoned]
Copy link

vercel bot commented Sep 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 30, 2024 4:38pm

[ghstack-poisoned]
Copy link
Contributor

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!!!! Yeah this makes sense, seems like we can adjust the merging logic to account for this case to keep the impact of fixing this case pretty limited.

[ghstack-poisoned]
@mofeiZ mofeiZ merged commit 845ee37 into gh/mofeiZ/20/base Sep 30, 2024
19 of 20 checks passed
mofeiZ added a commit that referenced this pull request Sep 30, 2024
Found when writing #31037, summary copied from comments:

This is an extreme edge case and not code we'd expect any reasonable developer to write. In most cases e.g. `(a?.b != null ? a.b : DEFAULT)`, we do want to take a dependency on `a?.b`.

I found this trying to come up with edge cases that break the current dependency + CFG merging logic. I think it makes sense to error on the side of correctness. After all, we still take `a` as a dependency if users write `a != null ? a.b : DEFAULT`, and the same fix (understanding the `<hoistable> != null` test expression) works for both. Can be convinced otherwise though!

ghstack-source-id: cc06afda59f7681e228495f5e35a596c20f875f5
Pull Request resolved: #31035
@mofeiZ mofeiZ deleted the gh/mofeiZ/20/head branch September 30, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants