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

Expand literals in comparisons when safe #2487

Merged
merged 5 commits into from
May 8, 2024

Conversation

max-hoffman
Copy link
Contributor

No description provided.

}

if rightLit != nil && leftGf != nil {
if types.IsSigned(left.Type()) && types.IsSigned(right.Type()) {
Copy link
Member

Choose a reason for hiding this comment

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

Seems kind of over specified? If this is a good idea then it's probably a good idea for other types too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made it more general in a way that I think is easy to understand as safe. Types are similar classes and column type is wider than literal. Crossing those two boundaries is doable but trickier, less common, and can depend on the expression type.

@max-hoffman max-hoffman marked this pull request as ready for review May 8, 2024 19:36
@max-hoffman
Copy link
Contributor Author

test bump correctness looks good, shipping

@max-hoffman max-hoffman merged commit e782297 into main May 8, 2024
7 checks passed
@max-hoffman max-hoffman deleted the max/lossless-comparison-literal-expansion branch May 8, 2024 21:36
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.

2 participants