Repository navigation
Deliberate misuse, sorted by what the compiler does with it - #2
Merged
Merged
Conversation
tests/check.sh builds seven wrong programs. tests/caught/ must fail to compile with the diagnostic named in the file's `# expect-error:` line — the four refusals PR #1 lists. tests/uncaught/ must compile with no diagnostic, run, and print the `# expect:` lines in order — the wrong answer, on purpose: the post's untracked Ctx dropping `totals` before the threads start, `opaque()` outside `run` doing the same, and a field-copy-then-deref reading a destroyed object. Both directions are claims about the compiler. A caught case that starts compiling means a stated guarantee is gone; an uncaught case that stops compiling means the compiler learned to see it — move the file over. The destructor in the uncaught cases poisons the cell to -1 and leaks it rather than freeing it: with a real free, the thousand writes corrupted the heap on some runs (pthread_join rc=3), and a test documenting undefined behaviour cannot itself be undefined. Poisoned, the misuse is a number — 499499 — and the harness held over 15 consecutive runs. The harness was checked in both directions: a caught case rewritten to compile and an uncaught case with its expectations reordered are each reported as FAIL. Run it as `pixi run check`; it says so if `mojo` is not on PATH. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015or6oTZmb7EQTXTbALbBXY
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.
Stacked on #1. Answers "how do we introduce bugs and find out whether the compiler catches them" with a harness that holds the compiler to a claim in both directions.
pixi run checkbuilds seven deliberately wrong programs:tests/caught/— must fail to compile, with the diagnostic named in the file's# expect-error:line. The four refusals from Keep the origin in the context type #1: sharing areadargument, sharing a temporary, returning aCtxto a local, aCtxoutliving its block.tests/uncaught/— must compile with no diagnostic, run, and print the# expect:lines in order — the wrong answer, reproduced on purpose:untracked_ctx_drops_early— the post'sCtx:totalsdestroyed before any thread startsopaque_escapes_origin—share(totals).opaque()outsiderun: the boundary of what origins coverfield_deref_after_last_use—totals.cell[]copies the pointer field, the struct dies, the deref reads a destroyed object;totals.sum()through a method gets499500If a caught case starts compiling, a guarantee the README states has gone. If an uncaught case stops compiling, the compiler learned to see something — move the file to
caught/, record the diagnostic, and the by-hand review list gets shorter.Two things found while writing it:
unsafe_freein the destructor, the thousand writes into the freed block corrupted the heap on some runs (pthread_join failed, rc=3). The destructor now poisons the cell to-1and leaks it, so the misuse is a number to assert — the sum comes out499499. Held over 15 consecutive runs.FAIL.CI runs
pixi run checkafter both programs.🤖 Generated with Claude Code
https://claude.ai/code/session_015or6oTZmb7EQTXTbALbBXY