Skip to content

Tag three rejection demos, and make the ledger say what each one proves - #572

Merged
godofecht merged 4 commits into
mainfrom
doc-examples-rejections
Aug 19, 2026
Merged

godofecht merged 4 commits into
mainfrom
doc-examples-rejections

Conversation

@godofecht

@godofecht godofecht commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Continues the doc-example work. unverified: 235 -> 232.

Three blocks that exist to be rejected

  • ROADMAP.md:441 — "This should ERROR, not warn"
  • docs/book/02-values-and-types.md:57 — "The following program is rejected"
  • docs/language/spans.md:165 — "A span may not outlive its storage"

None were tagged, so each counted as a failure.

Tagging alone was not enough

The ledger recorded the standalone parse error rather than the rejection the block demonstrates. A reader saw:

Top-level 'let' at line 1 must be 'let mut'

which is the harness failing to wrap a fragment, not the compiler rejecting anything. verify() now keeps the first failure that reached meaning and records that instead:

Cannot assign to immutable variable 'total' (use 'let mut')
span outlives borrowed storage `local` at line 3, column 5

The second is the exact string docs/language/spans.md quotes as the expected output. That claim is now checked against the compiler rather than asserted.

A ledger row that covered two blocks

The report counted 232 unverified against 231 ledger entries. The key is the path plus a hash of the code, so two byte-identical blocks in one file collided — VISION.md and lib/stdlib/audio/README.md each repeat a block verbatim. Keys now carry an occurrence suffix. It counts occurrences rather than using the line number, which would churn every time anything above the block is edited.

779 blocks now produce 779 distinct keys, and the two counts agree.

The convention was undocumented

expect-error, ignore=, preamble= and no-harness appeared only inside scripts/. A contributor writing a doc example had no way to know they exist. CONTRIBUTING.md now documents all four, plus the two facts that are not obvious: a block does not need a main, and an unknown info-string word fails loudly rather than silently verifying as ordinary code.

Verification

Check Result
pytest tests/ 1596 passed, 6 skipped
check_doc_examples.py --check-ledger no new unverified, counts agree at 232
check_doc_links.py all links and fragments resolve

Two new tests cover the occurrence key: that identical blocks get distinct keys, and that a block which moves keeps its key.

godofecht and others added 4 commits August 19, 2026 10:39
Three blocks exist to show the compiler refusing a program: a type mismatch
in ROADMAP.md, an assignment to an immutable binding in the book, and a span
outliving its storage. None were tagged, so each counted as a failure.

Tagging alone was not enough. The ledger recorded the standalone parse error
rather than the rejection the block demonstrates, so a reader saw

    Top-level 'let' at line 1 must be 'let mut'

which is the harness failing to wrap a fragment, not the compiler rejecting
anything. It now records the first failure that reached meaning:

    Cannot assign to immutable variable 'total' (use 'let mut')
    span outlives borrowed storage `local` at line 3, column 5

The second is the exact string docs/language/spans.md quotes as the expected
output, so that claim is now checked rather than asserted.

Two byte-identical blocks in one file shared a ledger row, because the key is
the path plus a hash of the code. That is why the report counted 232
unverified against 231 ledger entries. Keys now carry an occurrence suffix,
which stays stable when a block moves; line numbers would not.

CONTRIBUTING.md described no convention for any of this. The four info-string
words are now documented where someone writing a doc example will find them.

unverified: 235 -> 232.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@godofecht
godofecht merged commit d3cd578 into main Aug 19, 2026
20 checks passed
@godofecht
godofecht deleted the doc-examples-rejections branch August 19, 2026 10:45
godofecht added a commit that referenced this pull request Aug 19, 2026
#572 changed the key format and #574 changed which blocks pass, so the
checked-in ledger conflicted. Regenerated rather than hand-merged.

unverified: 235 -> 221 with both changes applied.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
godofecht added a commit that referenced this pull request Aug 19, 2026
* Make lib/stdlib/audio/README.md describe the API that exists

Every code block in this README failed to compile. Three sections named
functions that were never written:

  gpu_process_buffer(input, effect_kernel)   -> audio_gain_block(backend, buf, gain)
  simd_gain_f32x8(samples, gain)             -> audio_gain_interleaved_f32(...)
  graph_new(); graph_add_oscillator(...)     -> effect_chain_new(rate); effect_chain_*

The graph section described a node-and-edge API. What exists is a value:
each stage returns a new EffectChain, so the section is rewritten around
that rather than renamed onto it.

pattern_4 and euclidean_pattern were called with a trailing voice argument.
They take no such argument; pattern_4 always plays through bass and
pattern_8 through lead, and the comment in livecode.flow ("caller can modify
this pattern if needed") shows the parameter was intended and never added.
The README now says which voice each one uses.

Five blocks used `clock` without declaring it, and two used both `clock` and
`pos` at file scope with no enclosing function. A reader copying any of them
got the same errors CI now catches.

The GPU block is tagged ignore= rather than fixed: it links
runtime/audio_gpu_metal.m, which the doc example build does not compile. The
prose now gives the clang line, which it did not before.

unverified: 235 -> 224.

This turned up issue #573. lib/stdlib/audio/scales.flow returns fixed-size
arrays from every function, and `-> array<T, N>` lowers to a pointer into
the callee's dead frame, so all 25 such functions in the stdlib return
garbage. Added as a strict xfail in test_coverage_known_bugs.py so it
reports the moment it is fixed. The blocks here compile, which is all the
doc checker asserts; the one that also runs a scale function still prints
garbage until #573 is fixed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Drop the #573 xfail: PR #576 fixes the bug rather than recording it

The xfail asserted that -> array<T, N> stops returning stack memory. #576
makes that true, so keeping it here would XPASS and fail the build the moment
that lands. The real regression test lives with the fix, in
tests/integration/test_array_return.py, and reads the values back.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Regenerate the example ledger after rebasing onto the occurrence keys

#572 changed the key format and #574 changed which blocks pass, so the
checked-in ledger conflicted. Regenerated rather than hand-merged.

unverified: 235 -> 221 with both changes applied.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
godofecht added a commit that referenced this pull request Aug 19, 2026
) (#600)

PR #572 did this for expect-error blocks. Ordinary unverified ones still kept
the first failure, and standalone runs before the wrappers, so a statement
fragment was recorded as

    Top-level 'let' at line 1 must be 'let mut'

which is the harness failing to wrap a fragment, not the compiler saying
anything about the program. Where a later rung reached the type checker, that
is what the ledger now carries.

74 of the 221 entries move from a superficial parse error to the real reason:

    parse 173 -> 99
    types   29 -> 103
    clang   19 -> 19

The counts are unchanged; only the diagnosis is. That matters because the
ledger is the worklist for driving the remaining blocks to zero, and half of
it was describing the harness rather than the example.

Closes #588

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant