Skip to content

LSP: inactive regions and reachability (specs/lsp/inactive.t27) #12258

Closed

Description

@gHashTag

Inactive regions and reachability: show the user which code does not run. clangd greys out code under a false #if; Odin fades the untaken when branch; Pyright marks unreachable code. t27 has compile-time conditions and t27c deadcode, so the same fade is available. Part of the LSP epic, Refs #12209 (wave 2, beyond the standard). Only .t27: no code in any other language, not even scratch probes or a loader; see skill only-t27.

Depends on specs/lsp/analysis.t27 and specs/lsp/diagnostics.t27 (the Unnecessary tag). t27c deadcode is the reference for what is dead.

Prior art:

Boundary

  • specs/lsp/inactive.t27

User Scenarios

  • Given a block guarded by a compile-time condition that is false for the active target, when the snapshot is built, then the server sends t27/inactiveRegions with the range of that block, and the client shows it faded.
  • Given statements after an unconditional return, when diagnostics run, then they carry the Unnecessary tag and a hint unreachable code.
  • Given a private function nobody calls, when diagnostics run, then its name has the Unnecessary tag and the hint unused function, matching t27c deadcode.
  • Given the active target changes in settings, when the setting arrives, then the regions are recomputed and re-sent.
  • Given a region contains an error, when diagnostics run, then the error is still reported (inactive code must still parse), at hint severity if the setting says so.

Requirements

  • FR-001: The module MUST compute inactive regions from the compile-time conditions with the active target as input, unreachable ranges after terminators, and dead private items, and MUST return them as a sorted list of non-overlapping ranges.
  • FR-002: The module MUST send t27/inactiveRegions to clients that announced it, and MUST also publish the ranges as Unnecessary diagnostics for clients that did not.
  • FR-003: The dead-item list MUST equal the output of t27c deadcode on the same file; a test compares them on 10 specs.
  • FR-004: Regions MUST be recomputed on a target change and MUST not be re-sent when they are equal to the last ones.
  • FR-005: The module MUST NOT evaluate conditions itself; it reads the compiler's evaluation from the snapshot.

Success Criteria

  • At least 20 tests in specs/lsp/inactive.t27 pass, run on the lab with t27c test-report (exit 0), including the no-resend rule.
  • On the lab the dead-item agreement test passes on 10 named specs; the command and the list are pasted in the issue.
  • git diff --name-only master lists only specs/lsp/inactive.t27 (0 files in other languages).

Activity

  1. gHashTag commented on Nov 17, 2026

    @gHashTag
    CollaboratorAuthor

    LSP spec created (typecheck OK, tests pass).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/specs.t27 spec files and conformanceenhancementNew feature or requestspec

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions