Skip to content

Errors, where possible, should show both use and origin for erroring values #4326

Closed

Description

@sophiajt

From a recent fix:

Before:

Error: nu::shell::type_mismatch (link)

  × Type mismatch during operation.
   ╭─[entry nushell/engine-q#1:1:1]
 1 │ benchmark { echo a | each { $it + 10 } | length }
   ·                  ┬              ┬ ─┬
   ·                  │              │  ╰── int
   ·                  │              ╰── type mismatch for operator
   ·                  ╰── string
   ╰────

Now:

Error: nu::shell::type_mismatch (link)

  × Type mismatch during operation.
   ╭─[entry nushell/engine-q#8:1:1]
 1 │ benchmark { echo a | each { $it + 10 } | length }
   ·                             ─┬─ ┬ ─┬
   ·                              │  │  ╰── int
   ·                              │  ╰── type mismatch for operator
   ·                              ╰── string
   ╰────

While the second one is easier to debug, ideally we'd like to have both. Show the error on the use, but then have a secondary span that points to where this value originated.

Activity

  1. transferred this issue fromnushell/engine-qon Feb 7, 2022
  2. sophiajt commented on Aug 9, 2023

    @sophiajt
    ContributorAuthor

    After reviewing this, I think the second example is preferable as you are more focused on the error.

    Closing for now, but we should probably do a bit of an error review to make sure we have all the necessary info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions