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

Make snegate / unegate overflow handling consistent with other builtins. #4744

Merged
merged 2 commits into from
Dec 26, 2024

Conversation

zygoloid
Copy link
Contributor

Make int.snegate ignore the signedness of its operand and unconditionally check for signed overflow like all the other int.s* builtins do. Fix the prelude implementation of unary - for Core.UInt to use int.unegate instead of int.snegate.

Fix the test for unsigned negate to actually test negating unsigned integers, and add some tests that unary - also works.

Make snegate ignore the signedness of its operand and unconditionally
check for signed overflow like all the other s* builtins do. Fix the
prelude implementation of unary `-` for `Core.UInt` to use unegate
instead of snegate.
@zygoloid zygoloid requested a review from danakj December 26, 2024 20:26
@github-actions github-actions bot requested a review from jonmeow December 26, 2024 20:26
Copy link
Contributor

@chandlerc chandlerc left a comment

Choose a reason for hiding this comment

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

LG!

@chandlerc chandlerc added this pull request to the merge queue Dec 26, 2024
Merged via the queue into carbon-language:trunk with commit 7d8d59c Dec 26, 2024
8 checks passed
@zygoloid zygoloid deleted the core-negate-unsigned branch January 2, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants