Skip to content

✨Improve type error reporting with full ranges and minimal CLI output#1450

Merged
harehare merged 2 commits intomainfrom
improve-type-error-location-range-16838458524034640252
Mar 14, 2026
Merged

✨Improve type error reporting with full ranges and minimal CLI output#1450
harehare merged 2 commits intomainfrom
improve-type-error-location-range-16838458524034640252

Conversation

@harehare
Copy link
Copy Markdown
Owner

Modified TypeError in mq-check to store mq_lang::Range instead of a truncated start position. This enables precise error highlighting in the LSP and WASM interfaces, while keeping the CLI output focused on the error start position as requested.

Key changes:

  • Updated TypeError enum variants and location() method in mq-check/lib.rs.
  • Propagated full ranges through constraint generation and unification logic.
  • Updated mq-lsp to use the full range for accurate editor diagnostics.
  • Updated mq-wasm to expose full range data for web frontend consumers.
  • Configured CLI error output to display only the start position (line:col).
  • Fixed indentation in unify.rs and constraint.rs.
  • Updated unit tests to reflect the new range-based structure.

Modified `TypeError` in `mq-check` to store `mq_lang::Range` instead of a
truncated start position. This enables precise error highlighting in the
LSP and WASM interfaces, while keeping the CLI output focused on the
error start position as requested.

Key changes:
- Updated `TypeError` enum variants and `location()` method in `mq-check/lib.rs`.
- Propagated full ranges through constraint generation and unification logic.
- Updated `mq-lsp` to use the full range for accurate editor diagnostics.
- Updated `mq-wasm` to expose full range data for web frontend consumers.
- Configured CLI error output to display only the start position (`line:col`).
- Fixed indentation in `unify.rs` and `constraint.rs`.
- Updated unit tests to reflect the new range-based structure.

Co-authored-by: harehare <[email protected]>
Copilot AI review requested due to automatic review settings March 14, 2026 02:00
@harehare harehare changed the title Improve type error reporting with full ranges and minimal CLI output ✨Improve type error reporting with full ranges and minimal CLI output Mar 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates mq-check type errors to carry full mq_lang::Range information (instead of only a start position) so downstream consumers (LSP/WASM) can highlight precise spans, while keeping CLI output minimal by printing only the start line:col.

Changes:

  • Updated mq_check::TypeError variants and location() to store/return Option<mq_lang::Range> and propagated this through constraint generation and unification.
  • Updated mq-lsp diagnostics + filtering logic to use full ranges for more accurate editor highlighting.
  • Updated mq-wasm to emit diagnostics with start/end ranges for type errors.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test_error.mq Adds a minimal repro script that triggers a type error.
crates/mq-wasm/src/script.rs Emits type-check diagnostics using full Range (start/end).
crates/mq-lsp/src/server.rs Filters type errors using a set of source Ranges (per-source attribution).
crates/mq-lsp/src/error.rs Converts type errors into LSP diagnostics using the full Range.
crates/mq-check/src/unify.rs Stores full Range in type errors generated during unification.
crates/mq-check/src/main.rs Keeps CLI output minimal by printing only range.start as line:col.
crates/mq-check/src/lib.rs Changes TypeError to store Option<Range> and updates unit tests accordingly.
crates/mq-check/src/infer.rs Propagates full Range into emitted TypeErrors.
crates/mq-check/src/constraint.rs Propagates full Range into emitted TypeErrors during constraint generation.

Comment on lines +473 to +476
start_line: range.start.line.saturating_sub(1),
start_column: range.start.column.saturating_sub(1) as u32,
end_line: range.end.line.saturating_sub(1),
end_column: range.end.column.saturating_sub(1) as u32,
@harehare harehare merged commit 4e79485 into main Mar 14, 2026
4 checks passed
@harehare harehare deleted the improve-type-error-location-range-16838458524034640252 branch March 14, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants