Repository navigation
#276: SL-08, hexadecimal and decimal in the standard library (LexLeanStd.Numeral) — draft - #281
Closed
humuhumu33 wants to merge 1 commit into
Closed
humuhumu33 wants to merge 1 commit into
humuhumu33 wants to merge 1 commit into
Conversation
…Std.Numeral) The first member the self-hosted compiler needs. Five production roots for rust-std: decimal and hexNat (the digits of a natural number), hex (the lowercase digits of bytes), and the canonical readers parseDecimal and parseHex. Their oracles are the compiler's own readings: u64 formatting and parsing, canonical_digits and canonical_hex of surface::semantic, and Sha256Digest::to_hex; a canonical decimal past the target width is an overflow on both sides. The case (crates/conformance/src/cases/stdlib_numeral.rs) checks eligibility and exact effects, runs each member under the evaluator (600 runs) and its rendered package under rustc (3,000 runs), checks the round trips of each reader over its printer, plants a letter value in hexValue, and compares the certified export with the committed packages. Hand-written part only: roots.json gains the five roots, and the locks of stdlib, bootstrap and examples/helpdesk move. The stdlib records, goldens and production export are left to the maintainer's regeneration. Register 444. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
#276, first member:
SL-08, hexadecimal and decimal (LexLeanStd.Numeral) — draftRefs #276 (plan in the claim), #92.
What it adds
stdlib/src/Numeral.lex.tex, five production roots forrust-std, each held to the compiler's own reading (stage 0), not to a crate:decimal : Nat -> Bytesu64::to_stringhexNat : Nat -> Bytesformat!("{:x}")of au64parseDecimal : Bytes -> Option Natnoneunlesscanonical_digits, thenu64::from_str; past the width, an overflow on both sideshex : Bytes -> BytesSha256Digest::to_hexparseHex : Bytes -> Option Bytesnoneunlesscanonical_hex, then the digit pairsThe readers refuse exactly what the front end refuses: a leading zero, a sign, white space, an uppercase digit, an odd length.
The case,
crates/conformance/src/cases/stdlib_numeral.rs, runs in this order:parseDecimal (decimal n) = some nandparseHex (hex b) = some b.hexValuereads letters one too high.The corpus mixes numbers across the
u64range with canonical, mutated and arbitrary text.Register rows:
model/ids.toml, SPEC §31 and a §17.22 paragraph, CONFORMANCE.md, the scenario, CHANGELOG, VERIFICATION.md (the plant record), and the count at 444 in README, SPEC,repository.rsandspec_links.rs.tests/production-export/stdlib/roots.jsongains the five roots. The locks ofstdlib,bootstrapandexamples/helpdeskmove with the new entrypoint.Left to the regeneration
This PR moves identities: the stdlib project's source ID changes, so every stdlib package's
sourcesfield moves; the programs ofTextandSha256do not change. The PR carries the hand-written part only. These are not committed and wait for your wave:stdlib/expected/**(build goldens and verify records);tests/production-export/stdlib/packages/**;bootstrapandhelpdeskrecords the locks move.SL-05is #253'sBufferon this line, andrelease/v0.5already hasSL-05..SL-07. This row isSL-08to stay clear of both.Local evidence (WSL, normative host, head
e7f942c7conrelease/v0.49796067)cargo fmt --all -- --check,cargo xtask validate-model(444 ids),cargo xtask validate-spec-links(444 rows),cargo test -p repo-conformance --test bdd(5 passed),cargo clippy -p repo-conformance -p xtask --all-targets --all-features -D warnings: green.stdlib:lexlean fmt --check,check,buildgreen. All five roots are eligible, with declared effects equal to realized effects.conformance_sl_08passes in 296 s.conformance_sl_01andconformance_sl_02pass in 423 s together.stack_bounds::observe("stdlib/decimalis no package of the committed exports"), as expected until the regeneration.parseHexdisagrees on 250 of 600 runs. A pair containingfreads as empty bytes becausefbecomes 16.Not run locally:
golden,examplesandproduction-export(their records are the regeneration's),repro,deny, and the full workspacelint/test.After it lands
The private copies of these functions move to this module, by each module's owner: decimal in
CalculusCheck,RustValidate,AxiomOutput,PrimitiveScanandBuffer; hex inCalculusCheck,RustPrint,TokenAudit,PrimitiveScanandSha256. Next under #276:Order(SL-09).🤖 Generated with Claude Code