Skip to content

Add per-branch offset to IfBlock.elseif_branches for precise @elseif diagnostics #181

Description

@dean0x

Location: crates/mds-core/src/lint/rules/unreachable_branch.rs:135,164,193 (+ crates/mds-core/src/ast.rs:193)

unreachable-branch findings for @elseif clauses anchor to the enclosing @if offset rather than the offset of the offending @elseif branch, so the diagnostic caret points at the wrong location. The rule has no per-branch offset available: IfBlock.elseif_branches (crates/mds-core/src/ast.rs:193) carries no offset for each branch.

Deferred From: PR #171 (Closes #61) — mds lint release gate — cycle-2 review (I-28)
Review: .devflow/docs/reviews/feat-mds-lint-61/2026-07-12_0020/resolution-summary.md

Reason for Deferral:
The real fix adds a per-branch offset to the shared IfBlock.elseif_branches AST node (ast.rs:193), which ripples through the parser and every Node consumer (resolver / validator / build), for a cosmetic caret improvement. That blast radius exceeds the lint release gate.

Acceptance Criteria:

  • IfBlock.elseif_branches carries a per-branch source offset, populated by the parser
  • unreachable-branch @elseif findings anchor to the offending branch offset, not the enclosing @if
  • All downstream Node consumers (resolver, validator, build) updated for the new field; no behavior change outside diagnostics
  • A lint test asserts the caret column/offset points at the @elseif; all Rust tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    rustPull requests that update rust codetech-debtTechnical debt

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions