lower: separate compiler invariants from constructs a back end does not support #745

Open
opened 2026-11-13 12:39:36 +00:00 by orion · 0 comments
Collaborator

Context

reportUnsupported (compiler/src/ir/lower/context.trb:540) is the one exit of the lowering for two different things: a state the checker should have made impossible ("an expression without a type", "an Option without a Some case", "an assignment the checker did not resolve"), and a program the checker accepts and no back end builds ("an assignment to a captured binding", "a closure that captures the slot of a for var"). The audit counts about 440 call sites in compiler/src/ir/lower/ (call.trb 69, match.trb 58, derive.trb 46, expression.trb 39, closure.trb 35, collection.trb 32, quoted.trb 31, encoding.trb 27, statement.trb 19, place.trb 19) and 51 in the JavaScript and PHP back ends. A user cannot tell a compiler defect from a missing feature, and nobody can count the missing features.

Source

  • Cleanup audit 2026-11 (#742), finding F6; the report is docs/project/2026-11-cleanup-audit.md.

Goal

Two exits with two messages: an internal error ("this is a defect of the compiler, please report it", with the site) for an invariant, and "not supported yet" only for a construct that a user can write. Every call site uses the one that fits, and the user-reachable ones are listed.

Design record point

docs/internals/ (the architecture of the lowering); CONCEPT, "error messages" (a message says what the user can do).

Acceptance criteria

  • The lowering context has one function for an invariant and one for an unsupported construct; their messages differ as described, and a test pins both
  • Every call site under compiler/src/ir/lower/ and compiler/src/backend/ uses one of the two; reportUnsupported keeps no site that names a state the checker rules out
  • A page under docs/internals/ lists every user-reachable unsupported construct with its message and the back ends it applies to; a test fails when a new reportUnsupported site is not on the list
  • The output of an unsupported construct is unchanged apart from wording; the four gates and the fixpoint are green

Dependencies

None. #746 moves the user-reachable list to check time and builds on the list of this one.

Seed

None (no syntax, no change the seed has to read).

Size

One PR, two commits (the split with its tests, then the page with its test). Mechanical, about 490 sites.

## Context `reportUnsupported` (`compiler/src/ir/lower/context.trb:540`) is the one exit of the lowering for two different things: a state the checker should have made impossible ("an expression without a type", "an `Option` without a `Some` case", "an assignment the checker did not resolve"), and a program the checker accepts and no back end builds ("an assignment to a captured binding", "a closure that captures the slot of a `for var`"). The audit counts about 440 call sites in `compiler/src/ir/lower/` (call.trb 69, match.trb 58, derive.trb 46, expression.trb 39, closure.trb 35, collection.trb 32, quoted.trb 31, encoding.trb 27, statement.trb 19, place.trb 19) and 51 in the JavaScript and PHP back ends. A user cannot tell a compiler defect from a missing feature, and nobody can count the missing features. ## Source - Cleanup audit 2026-11 (#742), finding F6; the report is `docs/project/2026-11-cleanup-audit.md`. ## Goal Two exits with two messages: an internal error ("this is a defect of the compiler, please report it", with the site) for an invariant, and "not supported yet" only for a construct that a user can write. Every call site uses the one that fits, and the user-reachable ones are listed. ## Design record point `docs/internals/` (the architecture of the lowering); CONCEPT, "error messages" (a message says what the user can do). ## Acceptance criteria - [ ] The lowering context has one function for an invariant and one for an unsupported construct; their messages differ as described, and a test pins both - [ ] Every call site under `compiler/src/ir/lower/` and `compiler/src/backend/` uses one of the two; `reportUnsupported` keeps no site that names a state the checker rules out - [ ] A page under `docs/internals/` lists every user-reachable unsupported construct with its message and the back ends it applies to; a test fails when a new `reportUnsupported` site is not on the list - [ ] The output of an unsupported construct is unchanged apart from wording; the four gates and the fixpoint are green ## Dependencies None. #746 moves the user-reachable list to check time and builds on the list of this one. ## Seed None (no syntax, no change the seed has to read). ## Size One PR, two commits (the split with its tests, then the page with its test). Mechanical, about 490 sites.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#745
No description provided.