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

Fix issue with untagged variants and object when null is one case. #7303

Merged
merged 2 commits into from
Feb 17, 2025

Conversation

cristianoc
Copy link
Collaborator

Fixes #7289

The check emitted for case Object was simply type of ... === "object", though that is insufficient when the variant has one case corresponding to null. Now we check if such a variant case exists, and emit ... != null in addition.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Syntax Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: 6788385 Previous: 80744a5 Ratio
Print HeroGraphic.res - time/run 12.935322933333332 ms 12.308145193333333 ms 1.05

This comment was automatically generated by workflow using github-action-benchmark.

Fixes #7289

The check emitted for case `Object` was simply `type of ... === "object"`, though that is insufficient when the variant has one case corresponding to `null`.
Now we check if such a variant case exists, and emit `... != null` in addition.
@cristianoc cristianoc force-pushed the untagged-variants-null branch from fd6e41e to c4ba210 Compare February 17, 2025 16:08
@cristianoc cristianoc requested a review from cknitt February 17, 2025 16:12
Copy link
Member

@cknitt cknitt left a comment

Choose a reason for hiding this comment

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

Thanks a lot! 🎉

@cristianoc cristianoc merged commit 0b61e51 into master Feb 17, 2025
20 checks passed
@cristianoc cristianoc deleted the untagged-variants-null branch February 17, 2025 16:35
@zth
Copy link
Collaborator

zth commented Feb 17, 2025

This would be good to get into a v11 release too.

@cristianoc
Copy link
Collaborator Author

This issue does not occur in v11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect code emitted for untagged variant switch case
3 participants