feat(encoding): Decimal keeps every digit through EncodedValue.Exact, JSON, YAML and TOML #544
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/336-decimal-encoding"
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?
Closes #336
Task
Slice 4 of the Decimal design (DECIMAL.md section 14):
Encode/DecodeofDecimalwithEncodedValue.Exact, the JSON/YAML/TOML round trips, the conformance programdecimal-encoding, and the docs/status updates.What and why
EncodedValuegetscase Exact(value: Decimal).Values.decimalcompletes it,show()is the plain notation with the scale (19.90), it writes itself throughtarget.decimal.ValueDecoder:int/float/decimalread anExact(Int64.tryFrom,Float64.from, as-is). New optionexactAsText(set by TOML, which has no decimal type and writes a string).Float64prints back (1.5) stays aFloat; any other (19.90,1e3, 30 fraction digits, a 40-digit integer) becomes anExactwith its digits. AFloat64field still reads such a token as the nearestFloat64.std/sandboxcrossing:Exactcrosses asx19.90;.decimal.test.trbinstd/{encoding,json,yaml,toml},std/sandboxcrossing,std/uriroute; conformance programtests/conformance/decimal-encoding(+ README row).decimal.mdplanned -> stable, ROADMAP, encoding/number pages, inventory.Decision to review: the design said
ValueDecoder.decimalkeeps reading aString, DECIMAL.md section 11 says aDecimalfield that meets a string is refused. Resolved as: a string is refused unless the decoder islenient, built withexactAsText(TOML), or the string is a map key (URI route expansion keeps working).Test
Nothing was run locally (no toolchain on the box; the task forbids local suites/gates). CI is the first run.
decimal-encoding.expectedwas computed by hand;decimal-encoding.allocationsisunbudgeted: ...and needssh tools/conformance.sh --filter decimal-encoding --update-budgetson linux x86_64.skills/was edited by hand to mirror the three changed pages (docs skill docs skills --checkis the gate that will say if that is off).torb ir --statistics .is for CI to confirm.4cbaea9642d0bc330748Exactand conformance programs #336Exactand conformance programs #336Review of
a8228be(Argus). Approved.Checklist
decimal.test.trbin std/{encoding,json,yaml,toml}, sandbox crossing, uri route, plus conformancedecimal-encoding. CI green on this head (tier A, bootstrap, pdisc, gates).Exactis handled inshow,Encode,Values.decimal,ValueDecoder.int/float/decimal, JSON/YAML float-token split, sandboxx…;crossing. The string refusal indecimal()keepslenient(uri/regex), map keys and TOML (exactAsText) working. I walked the 7 lines ofdecimal-encoding.expectedagainst the program and they match.x, and a string-typedDecimalis now refused outside the listed cases (documented as the decision to review; I agree with it, it matches DECIMAL.md section 11).EncodedValuecase only, no new boundary.Non-blocking
tests/conformance/decimal-encodingand its hand-computed.expectedhave not run in CI. The first run will be on main or nightly. Please runsh tools/conformance.sh --filter decimal-encodingand--update-budgetson linux x86_64 as a follow-up, and replace theunbudgeted: … not measuredreason with a real budget (that marker is meant for programs whose count varies).1e2000000000now becomes anExact(scale fitsInt32), and itsshow()or encoding is a ~2 GB string, where it used to be aFloat.Float64.fromis native and safe, so typedFloat64fields are unaffected, butJson().decode<EncodedValue>followed byshow()orencodeon untrusted input can blow up memory. Consider a digit or scale cap inExactcreation from parsed text, or a note in DECIMAL.md section 11.ir,manifest,parse,tokens,ast,highlightandnativesparse withstd/cli(step 3 of #124) #550Decimalthat computes #34Decimalthat computes #34