8000 Clang-style diagnostics: show the failing source with the span underlined · Issue #657 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

Clang-style diagnostics: show the failing source with the span underlined #657

Description

@akoskovacs

Diagnostics today are one line: file.kex:2:3: error: Type mismatch: expected Integer, got String, in color or not. The reader has to open the file to see what it refers to.

Proposal: show the failing source under the message, with the span underlined, as clang (and rustc, Elm) do:

file.kex:2:20: Error [KEXET-0042]: Type mismatch: expected Integer, got String
    |
  2 |   let x: Integer = "a"
    |          -------   ^^^ this is a String
    |          |
    |          expected because of this annotation
  • The primary span underlined with ^, secondary spans (the annotation, the declaration a call resolved to) with - and a short label each.
  • Notes that already exist (note: triggered by tagged literal …) get their own snippet.
  • Off with --no-snippets, and in --json (which carries the spans as data instead); on by default on a terminal.
  • Colors follow --no-colors as today.

Needs: every diagnostic to carry a span (start and end), not only a start position; several secondary locations for the messages that name one (an expected type's annotation, an overload's declaration). Pairs with stable error codes (#656).

Filed for consideration: not decided.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0