lint: a case written with its type where the expected type names it #168

Open
opened 2026-10-08 00:58:18 +00:00 by orion · 5 comments
Collaborator

Context

The second rule torb lint names and does not build (torb-lint.md, "What is not decided", ROADMAP torb lint): a case written with its type where the expected type already names it (DecisionNode.SwitchCase(path) for .SwitchCase(path)). Split from #9, which keeps the closure rule.

Why it is not ready

The accepted record CLOSED-TRAITS, section 6 removes the leading dot: a case is written bare where the expected type names it, and phase 1a ("the largest mechanical change the repository has made since the Iterable rename", with the seed in between) is not built. A rule that rewrites to .Case now would sweep std and the compiler, and phase 1a would rewrite the same sites again. The decision is on this issue as an owner decision.

Goal (once decided)

A rule that finds a case written with its type at a position where the expected type names it, with a --fix that writes the short spelling the decision names; std and the compiler swept clean (no off-by-default, #157); documented in docs/tooling/torb-lint.md.

Acceptance criteria (draft, final after the decision)

  • The rule exists, always runs, has --fix, and finds only positions where the checker's expected type names the case's type (annotation, argument, field default, result, ==, arm of a typed match/if, typed collection element)
  • The standard library and the compiler are swept clean
  • Documented in docs/tooling/torb-lint.md

Size

The rule is one PR; the sweep may be a second one (about 1000 candidate sites in std and compiler/src).

## Context The second rule `torb lint` names and does not build ([torb-lint.md, "What is not decided"](https://git.torb.dev/torbscript/language/src/branch/main/docs/tooling/torb-lint.md), ROADMAP `torb lint`): a case written with its type where the expected type already names it (`DecisionNode.SwitchCase(path)` for `.SwitchCase(path)`). Split from #9, which keeps the closure rule. ## Why it is not ready The accepted record [CLOSED-TRAITS, section 6](https://git.torb.dev/torbscript/language/src/branch/main/docs/design/CLOSED-TRAITS.md) removes the leading dot: a case is written bare where the expected type names it, and phase 1a ("the largest mechanical change the repository has made since the `Iterable` rename", with the seed in between) is not built. A rule that rewrites to `.Case` now would sweep std and the compiler, and phase 1a would rewrite the same sites again. The decision is on this issue as an owner decision. ## Goal (once decided) A rule that finds a case written with its type at a position where the expected type names it, with a `--fix` that writes the short spelling the decision names; std and the compiler swept clean (no off-by-default, #157); documented in `docs/tooling/torb-lint.md`. ## Acceptance criteria (draft, final after the decision) - [ ] The rule exists, always runs, has `--fix`, and finds only positions where the checker's expected type names the case's type (annotation, argument, field default, result, `==`, arm of a typed `match`/`if`, typed collection element) - [ ] The standard library and the compiler are swept clean - [ ] Documented in `docs/tooling/torb-lint.md` ## Size The rule is one PR; the sweep may be a second one (about 1000 candidate sites in `std` and `compiler/src`).
Author
Collaborator

[loop:torbscript] owner decision: which spelling should the rule "a case written with its type where the expected type names it" move code to, and when?

Facts: today .Case is the short form (cases-and-match rule 2; CONTRIBUTING: "Prefer the short form where the expected type says which type is meant"). The accepted record CLOSED-TRAITS section 6 removes .Case in favour of the bare Case in phase 1a, which is not built yet and needs a seed refresh. About 1000 candidate sites in std and compiler/src.

Options:

  1. Build the rule now, target .Case, sweep now. Phase 1a later rewrites the same sites again (.Case to bare); two big mechanical diffs.
  2. Wait for phase 1a, then build the rule with the bare target; one sweep. This issue stays open and blocked on phase 1a.
  3. Drop the rule: phase 1a's migration makes it moot (the dot form is gone, Type.Case stays the spelling where no type is known); remove the "named, not built" entry from the docs and the ROADMAP.

Recommendation: 2 (or 3 if phase 1a is soon): no churn twice, and the target spelling is the one that stays.

[loop:torbscript] owner decision: which spelling should the rule "a case written with its type where the expected type names it" move code to, and when? Facts: today `.Case` is the short form (cases-and-match rule 2; CONTRIBUTING: "Prefer the short form where the expected type says which type is meant"). The accepted record CLOSED-TRAITS section 6 removes `.Case` in favour of the bare `Case` in phase 1a, which is not built yet and needs a seed refresh. About 1000 candidate sites in `std` and `compiler/src`. Options: 1. Build the rule now, target `.Case`, sweep now. Phase 1a later rewrites the same sites again (`.Case` to bare); two big mechanical diffs. 2. Wait for phase 1a, then build the rule with the bare target; one sweep. This issue stays open and blocked on phase 1a. 3. Drop the rule: phase 1a's migration makes it moot (the dot form is gone, `Type.Case` stays the spelling where no type is known); remove the "named, not built" entry from the docs and the ROADMAP. Recommendation: 2 (or 3 if phase 1a is soon): no churn twice, and the target spelling is the one that stays.
Author
Collaborator

Question q1 for torben (decision, blocking): Which spelling should the "case written with its type" lint rule move code to, and when?

v: 1
id: q1
to: torben
kind: decision
blocking: true
question: "Which spelling should the lint rule for a case written with its type move code to, and when? Details in the owner decision comment above."
options:
  - id: build-now
    label: Build now, target .Case
    detail: Sweep now; phase 1a rewrites the same sites again to bare Case (two large diffs)
  - id: wait-phase-1a
    label: Wait for phase 1a
    detail: Build the rule with the bare Case target after phase 1a; one sweep, issue stays blocked
  - id: drop
    label: Drop the rule
    detail: Phase 1a makes it moot; remove the named-not-built entry from docs and ROADMAP
recommendation: wait-phase-1a
asked_by: orion
**Question q1** for torben (decision, blocking): Which spelling should the "case written with its type" lint rule move code to, and when? ```hos-question v: 1 id: q1 to: torben kind: decision blocking: true question: "Which spelling should the lint rule for a case written with its type move code to, and when? Details in the owner decision comment above." options: - id: build-now label: Build now, target .Case detail: Sweep now; phase 1a rewrites the same sites again to bare Case (two large diffs) - id: wait-phase-1a label: Wait for phase 1a detail: Build the rule with the bare Case target after phase 1a; one sweep, issue stays blocked - id: drop label: Drop the rule detail: Phase 1a makes it moot; remove the named-not-built entry from docs and ROADMAP recommendation: wait-phase-1a asked_by: orion ```
Author
Collaborator

[loop:torbscript] refine: owner decision filed (q1), next: waiting (owner decision q1)

[loop:torbscript] refine: owner decision filed (q1), next: waiting (owner decision q1)
Author
Collaborator

[loop:torbscript] owner decision recorded (torben via WhatsApp, 2026-10-08 16:35 Europe/Berlin): "Okay, empfehulung akzeptiert" (option wait-phase-1a).

Resolution: the rule is built after phase 1a with the bare Case target, one sweep. The issue stays blocked on phase 1a (not ready); next: waiting (phase 1a), no owner question left.

[loop:torbscript] owner decision recorded (torben via WhatsApp, 2026-10-08 16:35 Europe/Berlin): "Okay, empfehulung akzeptiert" (option `wait-phase-1a`). Resolution: the rule is built after phase 1a with the bare `Case` target, one sweep. The issue stays blocked on phase 1a (not `ready`); next: waiting (phase 1a), no owner question left.
Owner

[owner-answer] q=q1 option=drop „Drop the rule“ 2026-10-29T22:52:43Z

[owner-answer] q=q1 option=drop „Drop the rule“ 2026-10-29T22:52:43Z
Sign in to join this conversation.
No labels
loop
ready
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#168
No description provided.