Skip to content

Change PipelineData::into_value to use internal Value's span before passed in span#14757

Merged
fdncred merged 1 commit intonushell:mainfrom
132ikl:into-value-span
Jan 5, 2025
Merged

Change PipelineData::into_value to use internal Value's span before passed in span#14757
fdncred merged 1 commit intonushell:mainfrom
132ikl:into-value-span

Conversation

@132ikl
Copy link
Copy Markdown
Member

@132ikl 132ikl commented Jan 5, 2025

Description

Changes the Value variant match arm of PipelineData::into_value to use the internal Value's span instead of the span passed in by the user. This aligns more closely with the ListStream and ByteStream match arms, which already use their internal span, and allows errors to provide better diagnostics since the span information doesn't get lost when into_value is called. At the suggestion of @cptpiepmatz, if the Value has Span::unknown for some reason, then we replace the Value's span with the passed in span.

Before:

{} | get foo bar
# => Error: nu::shell::column_not_found
# => 
# =>   × Cannot find column 'foo'
# =>    ╭─[entry #43:2:6]
# =>  2 │ {} | get foo bar
# =>    ·      ─┬─ ─┬─
# =>    ·       │   ╰── cannot find column 'foo'
# =>    ·       ╰── value originates here
# =>    ╰────

After:

{} | get foo bar
# => Error: nu::shell::column_not_found
# => 
# =>   × Cannot find column 'foo'
# =>    ╭─[entry #2:2:1]
# =>  2 │ {} | get foo bar
# =>    · ─┬       ─┬─
# =>    ·  │        ╰── cannot find column 'foo'
# =>    ·  ╰── value originates here
# =>    ╰────

User-Facing Changes

  • Some errors may have more accurate info about where the value originates from

Tests + Formatting

  • 🟢 toolkit fmt
  • 🟢 toolkit clippy
  • 🟢 toolkit test
  • 🟢 toolkit test stdlib

After Submitting

N/A

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Jan 5, 2025

Thanks!

@fdncred fdncred merged commit ed1381a into nushell:main Jan 5, 2025
@github-actions github-actions bot added this to the v0.102.0 milestone Jan 5, 2025
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