Repository navigation
fix(format): refuse unwritable quantities in cooklang source - #738
Closed
drawmeanelephant wants to merge 1 commit into
Closed
drawmeanelephant wants to merge 1 commit into
drawmeanelephant wants to merge 1 commit into
Conversation
A recipe scaled below zero emitted `@flour{-400%g}`, which reparses as
a *text* quantity — silently non-scalable and non-aggregating. There is
no source form for a negative (or non-finite) number, so the formatter
now fails with an error instead of corrupting the recipe.
Closes #722
Contributor
Author
|
Superseded by #755, which fixes the same defect more completely: it refuses before any output is written (this version could emit a partial recipe first) and also covers positive |
4 tasks done
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.
Closes #722
A recipe scaled below zero emitted
@flour{-400%g}, which reparses as{"type":"text","value":"-400","scalable":false}— the quantity silently stops scaling and aggregating. The grammar has no negative (or non-finite) numeric literal, so the formatter now rejects such quantities withcannot write quantity '-400' as cooklang sourceinstead of corrupting the recipe.Test plan
a_negative_quantity_fails_the_formatcargo test -p cooklang-formatgreen (35 tests)cook recipe neg.cook --scale=-1 -f cooklang→ clean error, exit 1