Give maxLen its own literal and repeats MaxRepeat; arg errors name the spelling and the range; write's comment says what Flush reports; assert 64-bit at compile time
Tests / vet + fmt + tests (pull_request) Successful in 59s
Tests / vet + fmt + tests (push) Successful in 6s

This commit was merged in pull request #3.
This commit is contained in:
2026-09-02 19:25:19 +02:00
parent a9552ed966
commit addba9abf7
7 changed files with 55 additions and 31 deletions
+6 -2
View File
@@ -82,8 +82,12 @@ func checkCalc(fields map[string]node, args []string) error {
return fmt.Errorf("calc(%q) divides by %s, which is always zero", args[0], divisor)
}
if len(args) == 2 {
if dp, err := plainInt(args[1]); err != nil || dp < 0 || dp > maxDecimals {
return fmt.Errorf("calc decimals %q must be a plain integer in 0..%d", args[1], maxDecimals)
dp, err := plainInt(args[1])
if err != nil {
return fmt.Errorf("calc decimals %w", err)
}
if dp < 0 || dp > maxDecimals {
return fmt.Errorf("calc decimals %d must be in 0..%d", dp, maxDecimals)
}
}
return nil