Repository navigation
Make every example in the expressions and matching chapter compile - #622
Merged
Merged
Conversation
docs/book/09-expressions-and-matching.md had nine unverified blocks and now has none. The chapter shows one form per block over bare stand-in names: `if n >= 0`, `while active`, `match point`. Repeating a declaration above each would bury the form the block exists to show, so the stand-ins live in a preamble fixture and the fragments stay one line each. That is what preamble= is for: context that is deliberately not on the page. Two blocks could not use it. Module statics may not hold a struct or enum type (#562), so `match point` and `choose mode.tag` declare their own subject now, one line each. Same for the array-pattern block, which matched on `samples` without one. The match-arms block returns strings from its arms, which only makes sense inside a function returning one. It said match n { 0 => { return "zero" } ... } with no enclosing function, so the harness wrapped it in `main` and the return type disagreed. Now `function describe(n: i32) -> string`. The ordering block is a catalogue of forms over illustrative collections (`values |> sort descending`, `players |> sortBy [...]`) and says so. unverified: 167 -> 159. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
godofecht
force-pushed
the
docs-book09-context
branch
from
August 20, 2026 17:10
c204da9 to
79f8c2e
Compare
godofecht
added a commit
that referenced
this pull request
Aug 20, 2026
Take the focused chapter 9 fixes from #622 and keep the audit branch's remaining documentation work on top.
godofecht
added a commit
that referenced
this pull request
Sep 7, 2026
Take the focused chapter 9 fixes from #622 and keep the audit branch's remaining documentation work on top.
godofecht
added a commit
that referenced
this pull request
Sep 7, 2026
Take the focused chapter 9 fixes from #622 and keep the audit branch's remaining documentation work on top.
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.
docs/book/09-expressions-and-matching.mdhad nine unverified blocks and now has none.unverified: 167 -> 159.The chapter's shape decided the fix
It shows one form per block over bare stand-in names:
Repeating
let n: i32 = 3above each of those would bury the form the block exists to show. So the stand-ins live in a preamble fixture and the fragments stay one line each. That is precisely whatpreamble=is for: context that is deliberately not on the page, as againstuses=, which is for context the page does show.Two blocks could not use it
Module statics may not hold a struct or enum type (#562), so
pointandmodecannot be declared in a preamble. Those blocks declare their own subject instead, one line each:Same for the array-pattern block, which matched on
sampleswithout one anywhere.A block that could not have compiled in any context
The match-arms example returns strings from its arms:
with no enclosing function, so the harness wrapped it in
mainand the return type disagreed. It only makes sense inside a function returning a string, and now says so:function describe(n: i32) -> string.One catalogue
The ordering block lists forms over illustrative collections (
values |> sort descending,players |> sortBy [desc .score, asc .name]) and now carries that as its reason.Verification
pytest tests/check_doc_examples.py --check-ledgercheck_doc_links.py