Repository navigation
Fix Decimal.Reduce's zero count for reused destinations - #167
Open
perfloop-agent wants to merge 1 commit into
Open
perfloop-agent wants to merge 1 commit into
perfloop-agent wants to merge 1 commit into
Conversation
Signed-off-by: Perfloop Agent <agent@perfloop.ai> Signed-off-by: Tomás Senart <ts@perfloop.ai>
|
Hi, I'm Tomás, I build Perfloop. I approved this contribution and will handle review feedback here. We found this bug while developing Perfloop's auto-formalization capabilities. We've had changes merged in Dolt, ClickHouse, Redis, Prometheus, RoaringBitmap, and more. If you'd like anything in this patch changed, just let me know and I'll update it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reusing a nonzero
Decimaldestination no longer changes the zero count returned byReducefor a finite zero operand.Only the returned count of removed zeros is wrong; the reduced
Decimalvalue is already correct. Within apd,Context.ReduceandErrDecimal.Reducepass the count on unchanged.Fix
The zero branch now reads the operand's digit count before resetting the destination. The reused-destination subtests fail on master with
got 1 zeros removed; master reads the destination at line 719 indecimal.go.This overlaps #165: its open diff still reads
d.NumDigits()in the same zero branch, so whichever merges second needs a one-line rebase. #166 sums counts from twoReducecalls (n + m); its first count depends on this correction for a reused zero destination.Tests
TestReduceindecimal_test.gocovers0,0E+3, and000with aNew(10, 0)destination. It checks the returned count and reduced zero value.Reuse prevalence and downstream impact remain unmeasured.
Case and evidence
Generated by Perfloop. Human sponsor: Tomás Senart.