Repository navigation
Show parse-time evaluation errors on one line - #19635
Merged
Merged
Conversation
`ShellError::wrap` turned an error from parse-time evaluation (a `const` value, the name given to `use`/`hide`/`source`, ...) into a `ParseError` whose message was the whole rendered report: color codes, box drawing and source snippet. The REPL status line, the language server, `--ide-check`, the debug adapter and `nu check --debug` all showed that report as one message. `wrap` now builds `ParseError::ParseTimeEval`, which keeps the report as its message (printed errors don't change) and the evaluation error itself. New `ParseError` methods give the one-line form: - `headline_and_label()`: headline plus first label, moved from the status line - `one_line_message()`: that line for a parse-time evaluation error, the usual message for every other error; used by nu-lsp, `--ide-check`, nu-dap and `nu check --debug` - `one_line_span()`: the span of that label when it lies inside the error's span, so editors underline the part that failed nu-mcp reports the evaluation error's own code, message, help and labels.
fdncred
added a commit
that referenced
this pull request
Nov 23, 2026
#19645) ## Description `repl::test_engine::const_switch_rejects_a_value_that_is_not_a_bool` fails on main (1dc849d), and so does every PR's root test job. #19638 added the test. Two PRs merged a few minutes before it changed what the test expects, and each of the three passed CI on its own base: - #19634 turned on `cell-path-types`, so the parser now knows `$r.a` in `const r = {a: 5}` is an `int`. It rejects `--chars=$r.a` with a type mismatch and never evaluates the const. - #19635 moved errors from parse-time evaluation out of `ParseError::LabeledError` and into the new `ParseError::ParseTimeEval`. The test covers the check #19638 added to const evaluation, so it needs an argument the parser can't type. It now passes `($r | get a)`. `get` returns `any`, so the parser lets it through and the const evaluation rejects it. The test matches the `CantConvert` inside `ParseTimeEval`, the same way `builtin_switch_rejects_a_value_that_is_not_a_bool` matches its error. ## User-facing changes (Release notes) <!-- This section is used (mostly as-is) for https://www.nushell.sh/blog/ Describe how Nushell behavior changes from a user's perspective. Do NOT describe internal Rust changes here. Write in a release note style, for example: - "Added support for..." - "Fixed an issue where..." - "Nushell now supports..." - "Improved performance of..." If your changes do NOT affect users (internal refactors, cleanup, etc.), just write: - "n/a" - "nan" - or similar This tells us the change should not appear in the changelog. Tips: - Focus on observable behavior - Include examples if helpful - Keep it concise You can: - Write a short paragraph (will appear as a bullet point), OR - Use headings (###) if your change needs more structure Avoid writing things like: - "In this PR, I refactored..." - "This updates internal code..." You may leave this blank until the PR is ready. --> ## Additional notes <!-- Optional. Examples: - fixes #123 - closes #456 - related #789 Anything else reviewers should know. Remove this section if not needed. -->
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.
Description
When evaluation fails at parse time, as in
hide $env.barorconst x = [] | first --strict,ShellError::wrapmade aParseErrorwhose message was the whole rendered report, with box drawing, source snippet and color codes. Everything that shows an error as one line got that report. The REPL status line printed it with each line break as a literal\n. The language server,nu --ide-check, the debug adapter andnu check --debugpassed it on as the message.wrapnow builds a newParseError::ParseTimeEval. Its message is still the report, so printed errors don't change, but it also keeps the evaluation error. The one-line places show that error's headline and first label. Editors underline the label's span instead of the whole value. The MCP server gets the evaluation error's own code, message, help and labels.User-facing changes (Release notes)
hide $env.bar. It shows✗ Not a constant: Value is not a parse-time constant.nu --ide-check, the debug adapter andnu check --debugshow these errors as one line. Editors underline the part that failed, such asinto intinconst d = ('abc' | into int).Additional notes