fix: reject duplicate remaining allotments#145
Conversation
|
Warning Review limit reached
More reviews will be available in 17 minutes and 57 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #145 +/- ##
==========================================
- Coverage 67.12% 67.11% -0.01%
==========================================
Files 47 47
Lines 5071 5076 +5
==========================================
+ Hits 3404 3407 +3
- Misses 1469 1471 +2
Partials 198 198 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
The general philosophy is that, with the new rewrite (well, not so "new" anymore), we separate static analysis and runtime errors, and reduce runtime errors to be more permissive and only block computations we can't possibly interpreter or succeed (unbound var, missing funds, etc). However, it's true that this one's actually confusing/misleading to allow, so it's probably a good idea to merge that.
Since we're here, I'd suggest to
- emit a more precise error on the last (redudant) clause, not on the whole allotment, which is a bit noisy on e.g. editors (however that's debatable, one may also argue that error is best on the whole source). This one's optional
- Avoiding writing the test using the flaky error message, but on the exact emitted struct. Also note most of the tests are on
interpreter_testinstead, whereas this test suite focuses more on the external contract. This one's more strongly suggested
1293e89 to
603cbd6
Compare
Summary
remainingclause at runtimeParse(...).Run(...)remainingcan appear before a variable portion, as covered bymetadata.numTDD evidence
RED before fix:
go test . -run TestRunRejectsDuplicateRemainingAllotments -count=1 -vreturned nil error for a source allotment with tworemainingclausesGREEN after fix:
go test . -run TestRunRejectsDuplicateRemainingAllotments -count=1 -vgo test ./...Notes
An initial broader runtime check for non-final
remainingbroke the existingmetadata.numspec, which usesremainingbefore a variable commission portion. This PR therefore fixes the duplicate-remaining corruption path without narrowing the current runtime language semantics.