decimal.util.is_decimal() does not fully validate its documented int/scale contract #55
Labels
No labels
coordination/cross-repo
coordination/needed
effort
large
effort
medium
effort
small
meta/duplicate
meta/planning
meta/wontfix
priority
high
priority
low
priority
medium
session
blocker
session
handover
session
next
status
blocked
status
done
status
in-progress
status
review
status
to-go
type
admin
type
bug
type
config
type
deployment
type
docs
type
enhancement
type
feature
type
handover
type
infrastructure
type
installation
type
maintenance
type
migration
type
research
type
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
DAW/daw-lua-common#55
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
decimal/util.lua'sM.is_decimal()does not fully validate theinternal decimal representation it documents:
Current check:
This accepts values that violate the documented contract, e.g.:
M.is_valid_scale()right next to it already implements the correctinteger check (
n % 1 == 0), butis_decimal()doesn't use it forscale, and has no equivalent check forintat all.An invalid scale/int can reach
decimal/convert.lua'stostring()(string.format/pow10 assuming an integer digit count) or
decimal/arith.lua's arithmetic, with undefined results instead of aclean
nil, daw_error/v1.Scope
is_decimal()rejects non-integerintis_decimal()rejects non-integerscale(reuseis_valid_scale()or equivalent logic)
int(NaN/Infinity) needs an explicitcheck or is already excluded by the integer check
Acceptance criteria
is_decimal()rejects the three example cases aboveRelated
Found during daw_i18n/v1 migration review of decimal/ (DAW/daw-lua-common#48)
Fixed: is_decimal() now requires int and scale to be integers (n % 1 == 0), which also rejects NaN/Infinity as a side effect since inf % 1 and nan % 1 both evaluate to nan, never 0.