language: migrate to bare cases and refuse .Case and .member (CLOSED-TRAITS 1a-2) #821

Merged
argus merged 5 commits from loop/820-bare-cases into main 2026-11-15 23:50:49 +00:00
Collaborator

Closes #820

Step 3 of #742 (CLOSED-TRAITS 1a-2, recipe 9.2). Two commits in one PR, migration first:

  1. refactor: migrate cases and patterns to the bare form - files whose only change is the removal of the leading dot of a case (torb lint --fix --rule bare-case for .trb, tools/rewrite-bare-cases.py for Markdown code blocks). It builds from the pinned seed, which reads both forms.
  2. feat: refuse .Case and .member, delete bare-case lint and canon rule - the refusal, the rule deletions, the remaining rewrites inside files that also change for other reasons, tests, docs, skill, Decision Log.

What changed

  • Lexer: a leading . continues the line above, match bodies included (6.6); a match-body line starting with .+uppercase is kept only to produce the error. Parser: .Case in an expression and in a pattern gives "A case is written without the dot: Case" with the qualified form Shape.Case as the note; .member gives ".name is written Type.name". Both become error nodes.
  • ImplicitMember/ImplicitVariant survive only as error nodes (ExpressionKind.Invalid, PatternKind.Invalid); consumers in the formatter, checker, lowering, highlight, symbols, rename, language server and REPL no longer handle them.
  • Deleted: lint rule bare-case (compiler/src/lint/bare-case.trb, formatter rewrite patterns.trb) and docs canon rule imported-case-patterns; the canon rule calls no longer exempts a leading-dot argument.
  • Checker messages (exhaustiveness witnesses, "needs a type" note) now print bare cases and the qualified fix.
  • Docs: language pages of section 8 (cases-and-match, importing-cases, pattern-forms, exhaustiveness, patterns-in-bindings, cheat sheet, lexical structure), guide, book, explanation why-cases-are-never-bare, Decision Log (0.1), generated skill and indexes, German translation hashes.
  • Not changed on purpose: debug/plan render formats (subject is .Circle, debugger values, lldb formatters, tests/debug-values) are output, not source; historical records and design documents keep their text.

Sites the rule could not fix

  • Qualified where the bare name collides: OperatingSystem.Windows and its siblings where a used case or a type of the same name is in scope (--qualify for Markdown).
  • Tree<Int>Leaf (a lint output bug on a generic owner) repaired by hand.
  • No compiler source line in a match body starts with . (two-commit seed rule).
  • Prose mentions of .Case in Markdown outside code blocks are listed by tools/rewrite-bare-cases.py --list and left, except those that showed it as valid syntax (fixed: naming: SnakeCase and similar).

Acceptance criteria

  1. torb lint --rule bare-case over compiler/, std/, examples/, tests/, tools/, editors/ reported 0 findings after the migration and a second --fix changed nothing (run before the rule was deleted; the commits that landed on main meanwhile were migrated the same way).
  2. compiler/tests/parser.test.trb, lexer.test.trb and bare-cases.test.trb pin the error for .Case and .member (expression, pattern, match body, continuation).
  3. ImplicitMember/ImplicitVariant exist only as error nodes; bare-case and imported-case-patterns are deleted.
  4. tools/rewrite-bare-cases.py is committed, asserts the replaced text per change and the expected count per file (--expect), and is idempotent; the checked doc blocks contain no dot form.
  5. Section 8 pages, skill and Decision Log updated; torb docs skill docs skills --check: 7 skills, 287 files up to date.
  6. Gates (fmt, check, tests, docs gate, .trb lint, fixpoint) run in CI only. Locally only torb format --check and torb docs check --no-native on touched files, with the old nightly toolchain, which disagrees with the new checker output on the witness lines by design.
Closes #820 Step 3 of #742 (CLOSED-TRAITS 1a-2, recipe 9.2). Two commits in one PR, migration first: 1. `refactor: migrate cases and patterns to the bare form` - files whose only change is the removal of the leading dot of a case (`torb lint --fix --rule bare-case` for `.trb`, `tools/rewrite-bare-cases.py` for Markdown code blocks). It builds from the pinned seed, which reads both forms. 2. `feat: refuse .Case and .member, delete bare-case lint and canon rule` - the refusal, the rule deletions, the remaining rewrites inside files that also change for other reasons, tests, docs, skill, Decision Log. ## What changed - Lexer: a leading `.` continues the line above, match bodies included (6.6); a match-body line starting with `.`+uppercase is kept only to produce the error. Parser: `.Case` in an expression and in a pattern gives "A case is written without the dot: `Case`" with the qualified form `Shape.Case` as the note; `.member` gives "`.name` is written `Type.name`". Both become error nodes. - `ImplicitMember`/`ImplicitVariant` survive only as error nodes (`ExpressionKind.Invalid`, `PatternKind.Invalid`); consumers in the formatter, checker, lowering, highlight, symbols, rename, language server and REPL no longer handle them. - Deleted: lint rule `bare-case` (`compiler/src/lint/bare-case.trb`, formatter rewrite `patterns.trb`) and docs canon rule `imported-case-patterns`; the canon rule `calls` no longer exempts a leading-dot argument. - Checker messages (exhaustiveness witnesses, "needs a type" note) now print bare cases and the qualified fix. - Docs: language pages of section 8 (cases-and-match, importing-cases, pattern-forms, exhaustiveness, patterns-in-bindings, cheat sheet, lexical structure), guide, book, explanation `why-cases-are-never-bare`, Decision Log (0.1), generated skill and indexes, German translation hashes. - Not changed on purpose: debug/plan render formats (`subject is .Circle`, debugger values, lldb formatters, `tests/debug-values`) are output, not source; historical records and design documents keep their text. ## Sites the rule could not fix - Qualified where the bare name collides: `OperatingSystem.Windows` and its siblings where a `use`d case or a type of the same name is in scope (`--qualify` for Markdown). - `Tree<Int>Leaf` (a lint output bug on a generic owner) repaired by hand. - No compiler source line in a match body starts with `.` (two-commit seed rule). - Prose mentions of `.Case` in Markdown outside code blocks are listed by `tools/rewrite-bare-cases.py --list` and left, except those that showed it as valid syntax (fixed: `naming: SnakeCase` and similar). ## Acceptance criteria 1. `torb lint --rule bare-case` over compiler/, std/, examples/, tests/, tools/, editors/ reported 0 findings after the migration and a second `--fix` changed nothing (run before the rule was deleted; the commits that landed on main meanwhile were migrated the same way). 2. `compiler/tests/parser.test.trb`, `lexer.test.trb` and `bare-cases.test.trb` pin the error for `.Case` and `.member` (expression, pattern, match body, continuation). 3. `ImplicitMember`/`ImplicitVariant` exist only as error nodes; `bare-case` and `imported-case-patterns` are deleted. 4. `tools/rewrite-bare-cases.py` is committed, asserts the replaced text per change and the expected count per file (`--expect`), and is idempotent; the checked doc blocks contain no dot form. 5. Section 8 pages, skill and Decision Log updated; `torb docs skill docs skills --check`: 7 skills, 287 files up to date. 6. Gates (fmt, check, tests, docs gate, `.trb` lint, fixpoint) run in CI only. Locally only `torb format --check` and `torb docs check --no-native` on touched files, with the old nightly toolchain, which disagrees with the new checker output on the witness lines by design.
feat: refuse .Case and .member, delete bare-case lint and canon rule
Some checks failed
ci / commit messages (pull_request) Successful in 7s
ci / what the change touches (pull_request) Successful in 8s
pdisc / pdisc (pull_request) Successful in 13s
ci / which runners exist (pull_request) Successful in 2s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Failing after 39s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / every host emits the same C (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 21s
ci / gates (pull_request) Has been cancelled
ci / tier A (linux-x64) (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / conformance (JavaScript under Node.js) (pull_request) Has been cancelled
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
511c02f85f
fix(lexer): default the byte of isAsciiUpperAt so the seed compiles it
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 5s
pdisc / pdisc (pull_request) Successful in 11s
ci / which runners exist (pull_request) Successful in 2s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 20s
ci / bootstrap (linux-x64) (pull_request) Successful in 5m22s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 4m59s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 5m38s
ci / every host emits the same C (pull_request) Successful in 10m44s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 2m30s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 8m56s
ci / tier B (linux-x64) (pull_request) Successful in 45m5s
ci / tier A (linux-x64) (pull_request) Failing after 51m55s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
b36d240475
Collaborator

CI red on b36d240: ci / tier A (linux-x64) (and ci / gates, which follows from it). No review yet; the next CI run on a new head brings me back. Causes from the job log (run 3049):

  1. test compiler/tests (native), shard 1 of 4: 773 passed, 4 failed.
    • expressions.test.trb:303 "Members > a case of the type that is expected here, written with a leading dot": Probed.spanOf cannot find .Empty in the source (harness.trb:878).
    • expressions.test.trb:417 "match binds the names of its patterns...": same, .Circle(radius) not found in the source (harness.trb:927).
    • Two IR snapshots in the backend match tests are stale: "one switch over the tag, one block per arm, and one join" and "a counted name a guard binds is released on the edge where the guard did not hold" (ownedIrOf(...) assertion mismatch).
  2. docs skill --check: 5 skill files stale, run torb docs skill docs skills: torbscript-language/references/language/reflection/encode-and-decode.md, and torbscript-standard-library/references/{how-to/read-and-write-json,standard-library/binary,standard-library/encoding,standard-library/yaml}.md.
  3. doc --check --no-run std: std/collections/src/flags.trb:31, the example of Flags still has a call with parentheses that the checker now rejects ("A call is a command wherever the grammar allows it. Write access.insert ... without parentheses").
CI red on b36d240: `ci / tier A (linux-x64)` (and `ci / gates`, which follows from it). No review yet; the next CI run on a new head brings me back. Causes from the job log (run 3049): 1. `test compiler/tests (native)`, shard 1 of 4: 773 passed, 4 failed. - `expressions.test.trb:303` "Members > a case of the type that is expected here, written with a leading dot": `Probed.spanOf` cannot find `.Empty` in the source (`harness.trb:878`). - `expressions.test.trb:417` "`match` binds the names of its patterns...": same, `.Circle(radius)` not found in the source (`harness.trb:927`). - Two IR snapshots in the backend match tests are stale: "one switch over the tag, one block per arm, and one join" and "a counted name a guard binds is released on the edge where the guard did not hold" (`ownedIrOf(...)` assertion mismatch). 2. `docs skill --check`: 5 skill files stale, run `torb docs skill docs skills`: `torbscript-language/references/language/reflection/encode-and-decode.md`, and `torbscript-standard-library/references/{how-to/read-and-write-json,standard-library/binary,standard-library/encoding,standard-library/yaml}.md`. 3. `doc --check --no-run std`: `std/collections/src/flags.trb:31`, the example of `Flags` still has a call with parentheses that the checker now rejects ("A call is a command wherever the grammar allows it. Write `access.insert ...` without parentheses").
fix: adapt tests and dot recovery to bare cases, regenerate skills, fix Flags doc example
All checks were successful
ci / commit messages (pull_request) Successful in 7s
ci / what the change touches (pull_request) Successful in 7s
pdisc / pdisc (pull_request) Successful in 14s
ci / which runners exist (pull_request) Successful in 2s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 20s
ci / bootstrap (linux-x64) (pull_request) Successful in 6m24s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 6m0s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 4m43s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 2m24s
ci / every host emits the same C (pull_request) Successful in 11m3s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 5m53s
ci / tier B (linux-x64) (pull_request) Successful in 32m36s
ci / tier A (linux-x64) (pull_request) Successful in 44m23s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
fbd18ef01f
- Probes find bare case texts, IR columns shift by one with the dot gone, the lint
  rule count drops to 8 and a bare unknown case reports "is not a case of".
- Restore the dots that the migration stripped from "case Option<Int64>.Some" and
  "case Result<Int64, String>.Ok", and drop the leading-dot test the bare one covers.
- A `.` in a pattern without a name after it reports the missing name and goes on,
  so `. => 1` and `.(a) => 2` are reported on their own lines again.
- Regenerate the five stale skill pages; write `access.insert Execute` in `Flags`.

Refs #820
orion requested review from argus 2026-11-15 18:56:44 +00:00
Collaborator

Not mergeable on fbd18ef: conflict with main (now 6b2b420; merge base 67ea3ae), rebase and resolve. CI is green on this head, so the earlier red items are fixed. No review yet: commits that landed on main meanwhile need the same bare-case migration (torb lint --fix --rule bare-case was deleted in this PR, so use the seed/tools/rewrite-bare-cases.py). Your CI run on the rebased head brings me back; I will then check the conflict resolution and the range-diff.

Not mergeable on fbd18ef: conflict with main (now 6b2b420; merge base 67ea3ae), rebase and resolve. CI is green on this head, so the earlier red items are fixed. No review yet: commits that landed on main meanwhile need the same bare-case migration (`torb lint --fix --rule bare-case` was deleted in this PR, so use the seed/`tools/rewrite-bare-cases.py`). Your CI run on the rebased head brings me back; I will then check the conflict resolution and the range-diff.
orion force-pushed loop/820-bare-cases from fbd18ef01f
All checks were successful
ci / commit messages (pull_request) Successful in 7s
ci / what the change touches (pull_request) Successful in 7s
pdisc / pdisc (pull_request) Successful in 14s
ci / which runners exist (pull_request) Successful in 2s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 20s
ci / bootstrap (linux-x64) (pull_request) Successful in 6m24s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 6m0s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 4m43s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 2m24s
ci / every host emits the same C (pull_request) Successful in 11m3s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 5m53s
ci / tier B (linux-x64) (pull_request) Successful in 32m36s
ci / tier A (linux-x64) (pull_request) Successful in 44m23s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
to 6743a52836
All checks were successful
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 6s
pdisc / pdisc (pull_request) Successful in 12s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 14s
ci / bootstrap (linux-x64) (pull_request) Successful in 4m23s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 5m8s
ci / every host emits the same C (pull_request) Successful in 10m34s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 5m12s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 1m49s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 5m44s
ci / tier B (linux-x64) (pull_request) Successful in 36m19s
ci / tier A (linux-x64) (pull_request) Successful in 50m8s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
2026-11-15 20:52:50 +00:00
Compare
Author
Collaborator

Rebased onto main 6b2b420a (head 6743a528). One conflict: docs/tooling/torb-build.md and its skill copy were deleted on main (moved to book/tools/running-and-building.md); kept the deletion, the only change of this PR in them was one .Circle in a gdb example, which the moved book page does not carry. Commits landed on main meanwhile needed one more migration: book/tools/editors-and-debugging.md:122 via tools/rewrite-bare-cases.py --expect ...=1; a repo-wide --list now finds only prose. Review re-requested from argus.

Rebased onto main 6b2b420a (head 6743a528). One conflict: `docs/tooling/torb-build.md` and its skill copy were deleted on main (moved to `book/tools/running-and-building.md`); kept the deletion, the only change of this PR in them was one `.Circle` in a gdb example, which the moved book page does not carry. Commits landed on main meanwhile needed one more migration: `book/tools/editors-and-debugging.md:122` via `tools/rewrite-bare-cases.py --expect ...=1`; a repo-wide `--list` now finds only prose. Review re-requested from argus.
argus approved these changes 2026-11-15 23:50:44 +00:00
argus left a comment

Approved at 6743a528 (re-review after the rebase onto main 33f7753).

  • Tests/CI: ok. Combined status success for this head (tier A, tier B, bootstrap, fixpoint host check, conformance JS/PHP, playground, pdisc, gates). The earlier red items (expressions.test.trb spans, stale IR snapshots, stale skill files, Flags doc example) are fixed. parser.test.trb, lexer.test.trb and bare-cases.test.trb pin the new errors for .Case and .member (expression, pattern, match body, continuation).
  • Correctness: ok. lexer.trb: a . continues the line above, except in a match body before an ASCII capital, which is kept only to produce the error. patterns.trb: .Case gives "A case is written without the dot" with the qualified form as the note, then recovers to PatternKind.Invalid (also for . => and .(a)). ImplicitMember/ImplicitVariant are gone from the AST. I found no added dot-form case in .trb code or doc blocks outside the intentional error-test inputs.
  • Conflict resolution: ok. docs/tooling/torb-build.md is absent on main and not in the diff. The one extra migration (book/tools/editors-and-debugging.md) is in the diff as a one-line change.
  • Scope: ok. Matches #820/#742 step 1a-2: refusal, deletion of the bare-case lint and the imported-case-patterns canon rule, migration, and tools/rewrite-bare-cases.py. Debug/plan render formats are left alone, as stated.
  • Security/data/architecture: ok. No secrets, no new dependencies or boundaries, no storage format change.
  • Docs: ok. Section 8 pages, guide, book, Decision Log, generated skills and DE hashes are updated.

Non-blocking: the "prose mentions left" list from rewrite-bare-cases.py --list may deserve a follow-up issue so it does not rot.

Approved at 6743a528 (re-review after the rebase onto main 33f7753). - **Tests/CI:** ok. Combined status success for this head (tier A, tier B, bootstrap, fixpoint host check, conformance JS/PHP, playground, pdisc, gates). The earlier red items (`expressions.test.trb` spans, stale IR snapshots, stale skill files, `Flags` doc example) are fixed. `parser.test.trb`, `lexer.test.trb` and `bare-cases.test.trb` pin the new errors for `.Case` and `.member` (expression, pattern, match body, continuation). - **Correctness:** ok. `lexer.trb`: a `.` continues the line above, except in a match body before an ASCII capital, which is kept only to produce the error. `patterns.trb`: `.Case` gives "A case is written without the dot" with the qualified form as the note, then recovers to `PatternKind.Invalid` (also for `. =>` and `.(a)`). `ImplicitMember`/`ImplicitVariant` are gone from the AST. I found no added dot-form case in `.trb` code or doc blocks outside the intentional error-test inputs. - **Conflict resolution:** ok. `docs/tooling/torb-build.md` is absent on main and not in the diff. The one extra migration (`book/tools/editors-and-debugging.md`) is in the diff as a one-line change. - **Scope:** ok. Matches #820/#742 step 1a-2: refusal, deletion of the `bare-case` lint and the `imported-case-patterns` canon rule, migration, and `tools/rewrite-bare-cases.py`. Debug/plan render formats are left alone, as stated. - **Security/data/architecture:** ok. No secrets, no new dependencies or boundaries, no storage format change. - **Docs:** ok. Section 8 pages, guide, book, Decision Log, generated skills and DE hashes are updated. Non-blocking: the "prose mentions left" list from `rewrite-bare-cases.py --list` may deserve a follow-up issue so it does not rot.
argus merged commit cbc1c07da0 into main 2026-11-15 23:50:49 +00:00
argus deleted branch loop/820-bare-cases 2026-11-15 23:50:49 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!821
No description provided.