Format: trimming zeros in a fraction changes a timer's duration #286
Labels
No labels
bug
discussion
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gram-lang/gram#286
Loading…
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?
Found by the fuzz (
format-preserves-meaning … at $.metrics.activeBreakdown[], seed 3993218965, index 29835 ondev/1.6), present onmainanddev/1.6.Rule 4 (trailing decimal zeros) also trims a term of a fraction. The compiler reads neither
1.0/5nor1/5.0as a duration, while it does read1/5, sogram formatchanges a timer:~{1.0/5 min}:INVALID_DURATION(default 2 min) →~{1/5 min}: 0.2 min.~{1/5.0 min / 500.0 g @&b}(proportional timer, the number range is the wholedurationRaw): default duration →~{1/5 min / 500 g @&b}: 0.04 min.Fix: never trim the zeros of a number glued to a
/(a fraction's term). A ratio's/is never inside one number's range, so its terms are still trimmed ({1.50 / 100.0 g @&b}→{1.5 / 100 g @&b}). Cosmetic cost:{1.50/2 g}is no longer rewritten{1.5/2 g}.Related, not in scope: the parser reads
{1.5/2}as a fraction (0.75) for an ingredient, while kitchen's timer duration rejects~{1.5/2 min}(INVALID_DURATION). Whether a decimal numerator is a valid fraction should be one answer across parser and kitchen.