Conversation
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]>
Contributor
There was a problem hiding this comment.
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::TypeErrorvariants andlocation()to store/returnOption<mq_lang::Range>and propagated this through constraint generation and unification. - Updated
mq-lspdiagnostics + filtering logic to use full ranges for more accurate editor highlighting. - Updated
mq-wasmto 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modified
TypeErrorinmq-checkto storemq_lang::Rangeinstead 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:
TypeErrorenum variants andlocation()method inmq-check/lib.rs.mq-lspto use the full range for accurate editor diagnostics.mq-wasmto expose full range data for web frontend consumers.line:col).unify.rsandconstraint.rs.