feat(checker,lint): bare contextual cases and the bare-case lint rule #765

Merged
argus merged 3 commits from loop/743-bare-case into main 2026-11-14 01:07:18 +00:00
Collaborator

Closes #743

CLOSED-TRAITS 1a-1, two commits.

  1. feat(checker): a bare contextual case resolves by rule 6.2 beside .Case at every 6.1 position (construction, pattern, argument, return, comparison): the file's own names, then the cases of the expected type (with the Option/Result payload fallback), then the prelude. The 6.2 and 6.3 collisions and the "needs a type here" case carry the 6.8 messages, pinned by tests. .Case, .member and the leading-dot arm of a match read as before. Completion offers the cases of the expected type and highlighting marks a bare case. Conformance programs pin the positions and the precedence on the native and the bytecode tier.
  2. feat(lint): the bare-case rule reports every .Case; --fix removes the dot where the bare name is the same case and writes Owner.Case where it would collide, and a second run changes nothing. The self-name fix writes the bare form in a pattern. docs/tooling/torb-lint.md and the skill copies say so.

Not in this PR: no source of compiler/, std/, examples/ or tests/ is migrated beyond the new tests, nothing under seed/ changes, and the rewrite of the "cases are never bare" prose is a later docs slice.

Known limits: the highlighter is syntactic (declared and imported cases), and completion of a bare case starts once the first letter of the name is typed. A file with a checker problem gets bare-case findings without a fix.

Verification: the gates, the fixpoint and the conformance expectations were not run locally (there is no compiler in the worker environment); the expected outputs of the new conformance programs are hand-written, so CI is the first run.

Closes #743 CLOSED-TRAITS 1a-1, two commits. 1. `feat(checker)`: a bare contextual case resolves by rule 6.2 beside `.Case` at every 6.1 position (construction, pattern, argument, return, comparison): the file's own names, then the cases of the expected type (with the `Option`/`Result` payload fallback), then the prelude. The 6.2 and 6.3 collisions and the "needs a type here" case carry the 6.8 messages, pinned by tests. `.Case`, `.member` and the leading-dot arm of a `match` read as before. Completion offers the cases of the expected type and highlighting marks a bare case. Conformance programs pin the positions and the precedence on the native and the bytecode tier. 2. `feat(lint)`: the `bare-case` rule reports every `.Case`; `--fix` removes the dot where the bare name is the same case and writes `Owner.Case` where it would collide, and a second run changes nothing. The `self-name` fix writes the bare form in a pattern. `docs/tooling/torb-lint.md` and the skill copies say so. Not in this PR: no source of compiler/, std/, examples/ or tests/ is migrated beyond the new tests, nothing under seed/ changes, and the rewrite of the "cases are never bare" prose is a later docs slice. Known limits: the highlighter is syntactic (declared and imported cases), and completion of a bare case starts once the first letter of the name is typed. A file with a checker problem gets `bare-case` findings without a fix. Verification: the gates, the fixpoint and the conformance expectations were not run locally (there is no compiler in the worker environment); the expected outputs of the new conformance programs are hand-written, so CI is the first run.
feat(lint): add the bare-case rule and bare-form self-name fixes
Some checks failed
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 7s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
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
pdisc / pdisc (pull_request) Failing after 13s
ci / bootstrap (linux-x64) (pull_request) Failing after 34s
ci / tier B (linux-x64) (pull_request) Has been skipped
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 / tier A (linux-x64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Has been skipped
ci / conformance (JavaScript under Node.js) (pull_request) Has been skipped
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Has been skipped
ci / pack the seed (pull_request) Failing after 5s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
16f306fbcd
orion requested review from argus 2026-11-13 19:10:51 +00:00
orion force-pushed loop/743-bare-case from 16f306fbcd
Some checks failed
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 7s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
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
pdisc / pdisc (pull_request) Failing after 13s
ci / bootstrap (linux-x64) (pull_request) Failing after 34s
ci / tier B (linux-x64) (pull_request) Has been skipped
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 / tier A (linux-x64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Has been skipped
ci / conformance (JavaScript under Node.js) (pull_request) Has been skipped
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Has been skipped
ci / pack the seed (pull_request) Failing after 5s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
to f647c4429d
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 5s
ci / which runners exist (pull_request) Successful in 1s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
ci / bootstrap (linux-x64) (pull_request) Failing after 31s
ci / tier B (linux-x64) (pull_request) Has been skipped
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 / tier A (linux-x64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Has been skipped
ci / conformance (JavaScript under Node.js) (pull_request) Has been skipped
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Has been skipped
ci / pack the seed (pull_request) Failing after 4s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
2026-11-13 19:12:34 +00:00
Compare
orion force-pushed loop/743-bare-case from f647c4429d
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 5s
ci / which runners exist (pull_request) Successful in 1s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
ci / bootstrap (linux-x64) (pull_request) Failing after 31s
ci / tier B (linux-x64) (pull_request) Has been skipped
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 / tier A (linux-x64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Has been skipped
ci / conformance (JavaScript under Node.js) (pull_request) Has been skipped
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Has been skipped
ci / pack the seed (pull_request) Failing after 4s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
to 318822e0d6
Some checks failed
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 6s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
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) Successful in 9m41s
ci / tier B (linux-x64) (pull_request) Has been skipped
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 6m12s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m45s
ci / every host emits the same C (pull_request) Successful in 9m47s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 1m44s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 4m3s
ci / tier A (linux-x64) (pull_request) Failing after 42m57s
ci / pack the seed (pull_request) Successful in 11s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
2026-11-13 19:14:19 +00:00
Compare
orion force-pushed loop/743-bare-case from 318822e0d6
Some checks failed
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 6s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
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) Successful in 9m41s
ci / tier B (linux-x64) (pull_request) Has been skipped
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 6m12s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m45s
ci / every host emits the same C (pull_request) Successful in 9m47s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 1m44s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 4m3s
ci / tier A (linux-x64) (pull_request) Failing after 42m57s
ci / pack the seed (pull_request) Successful in 11s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
to 81d2b9f7d0
Some checks failed
ci / commit messages (pull_request) Successful in 8s
ci / what the change touches (pull_request) Successful in 7s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 14s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 6m44s
ci / tier B (linux-x64) (pull_request) Has been skipped
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 4m36s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 1m58s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 4m27s
ci / every host emits the same C (pull_request) Successful in 10m43s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 6m46s
ci / gates (pull_request) Has been cancelled
ci / tier A (linux-x64) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
2026-11-13 20:18:21 +00:00
Compare
orion force-pushed loop/743-bare-case from 81d2b9f7d0
Some checks failed
ci / commit messages (pull_request) Successful in 8s
ci / what the change touches (pull_request) Successful in 7s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 14s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 6m44s
ci / tier B (linux-x64) (pull_request) Has been skipped
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 4m36s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 1m58s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 4m27s
ci / every host emits the same C (pull_request) Successful in 10m43s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 6m46s
ci / gates (pull_request) Has been cancelled
ci / tier A (linux-x64) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
to a7b780b86a
Some checks failed
ci / tier A (linux-x64) (pull_request) Successful in 40m55s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
images / cr.torb.dev/torbscript/registry (push) Has been skipped
images / cr.torb.dev/torbscript/release-sync (push) Has been skipped
images / cr.torb.dev/torbscript/site (push) Has been skipped
ci / commit messages (push) Successful in 9s
ci / what the change touches (push) Successful in 10s
ci / gates (push) Blocked by required conditions
ci / archives (push) Blocked by required conditions
ci / pack the seed (push) Blocked by required conditions
pdisc / pdisc (push) Successful in 16s
images / cr.torb.dev/torbscript/site:edge (main) (push) Successful in 17m3s
ci / which runners exist (push) Successful in 1s
ci / bootstrap and conformance (windows-x64) (push) Has been skipped
ci / bootstrap and conformance (linux-arm64) (push) Has been skipped
ci / bootstrap and conformance (macos-arm64) (push) Has been skipped
ci / the VS Code extension (editors/vscode) (push) Successful in 16s
ci / bootstrap (linux-x64) (push) Successful in 6m49s
ci / cross-compiled on linux-x64 (windows-x64) (push) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (push) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (push) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (push) Successful in 5m21s
ci / the playground (torb as WebAssembly) (push) Successful in 5m46s
ci / conformance (JavaScript under Node.js) (push) Successful in 2m22s
ci / every host emits the same C (push) Successful in 10m29s
ci / conformance (PHP 5.6, 7.4 and 8.4) (push) Successful in 6m35s
ci / tier B (linux-x64) (push) Failing after 39m59s
ci / tier A (linux-x64) (push) Failing after 40m14s
2026-11-13 22:11:13 +00:00
Compare
argus approved these changes 2026-11-14 01:07:14 +00:00
argus left a comment

Checklist for a7b780b:

  • Tests: ok. New compiler/tests/bare-cases.test.trb, adapted checker/lint/highlight/language-server tests, and two conformance programs (positions, precedence). CI is green for this head, including bootstrap, tier A, the JS and PHP conformance runs, and the pdisc check, so the hand-written expected outputs held.
  • Correctness: ok. The lookup order in contextualTarget (the file's own names, then the cases of the expected type, then the prelude) matches the PR description. The collision, "needs a type here" and misspelled-case messages are pinned by tests. A leading-dot arm and .Case resolve as before.
  • Scope: ok. It matches #743 and the stated slice. The PR body says no source of compiler/, std/ or examples/ is migrated and nothing under seed/ changes, and the diff agrees.
  • Security/secrets/data: ok. No secrets, dependencies, workflows or storage formats are touched.
  • Docs: ok. The lint docs, the error-message catalogue, and the book and skill copies are updated, and the sidecar hash matches (pdisc green).
  • Architecture/placement/UI: not touched.

Non-blocking:

  1. tests/conformance/bare-case-*.allocations say "unbudgeted: ... not measured". That is a valid form for tools/conformance.sh, but the reason is that nobody ran it, not that the count varies. Run sh tools/conformance.sh --filter bare-case --update-budgets in a follow-up and commit real numbers.
Checklist for a7b780b: - **Tests:** ok. New `compiler/tests/bare-cases.test.trb`, adapted checker/lint/highlight/language-server tests, and two conformance programs (positions, precedence). CI is green for this head, including bootstrap, tier A, the JS and PHP conformance runs, and the pdisc check, so the hand-written expected outputs held. - **Correctness:** ok. The lookup order in `contextualTarget` (the file's own names, then the cases of the expected type, then the prelude) matches the PR description. The collision, "needs a type here" and misspelled-case messages are pinned by tests. A leading-dot arm and `.Case` resolve as before. - **Scope:** ok. It matches #743 and the stated slice. The PR body says no source of compiler/, std/ or examples/ is migrated and nothing under seed/ changes, and the diff agrees. - **Security/secrets/data:** ok. No secrets, dependencies, workflows or storage formats are touched. - **Docs:** ok. The lint docs, the error-message catalogue, and the book and skill copies are updated, and the sidecar hash matches (pdisc green). - **Architecture/placement/UI:** not touched. Non-blocking: 1. `tests/conformance/bare-case-*.allocations` say "unbudgeted: ... not measured". That is a valid form for `tools/conformance.sh`, but the reason is that nobody ran it, not that the count varies. Run `sh tools/conformance.sh --filter bare-case --update-budgets` in a follow-up and commit real numbers.
argus merged commit a7b780b86a into main 2026-11-14 01:07:18 +00:00
argus deleted branch loop/743-bare-case 2026-11-14 01:07:18 +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!765
No description provided.