Skip to content

Inconsistent error highlighting for type mismatches on binary operations #7289

@epbuennig

Description

@epbuennig

Describe the bug

When trying to evaluate a binary addition with mismatched types, e.g.: int + string, the ordering of the types affects the preventative error highlighting.
Attempting to evaluate string + int highlights the +, whereas int + string highlights $var.

How to reproduce

  1. nu
  2. let $val = 10
  3. let $var = "10"
  4. $val + $var
  5. $var + $val

Expected behavior

Both operations highlight the right most term, xor the operator.

Screenshots

image

Configuration

key value
version 0.71.0
branch makepkg
commit_hash 6cc4ef6
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.65.0 (Arch Linux rust 1:1.65.0-1)
cargo_version cargo 1.65.0
pkg_version 0.71.0
build_time 2022-11-09 06:34:03 +00:00
build_rust_channel release
features database, dataframe, default, trash, which, zip
installed_plugins

Additional context

No Response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:error-handlingHow errors in externals/nu code are caught or handled programmatically (see also unhelpful-error)category:inconsistent-behaviorBehavior between different commands or types inconsistent/unexpectedpolishthis problem makes nu feel unpolishedstatus:needs-designthis feature requires design

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions