Skip to content

Inconsistent error highlighting for type mismatches on binary operations #7289

Closed

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

Activity

  1. changed the title [-]Inconsistent error messages for type mismatches on binary operations[/-] [+]Inconsistent error highlighting for type mismatches on binary operations[/+] on Nov 30, 2022
  2. added
    polish
    A:error-unhelpful
    category:inconsistent-behavior
    on Nov 30, 2022
  3. epbuennig commented on Nov 30, 2022

    @epbuennig
    Author

    Behaves as expected for T - U and U - T, as well as /, mod and **, I assume this goes for all other operators and this is perhaps related to the different implementations of string + string and int + int.
    image

  4. added
    status:needs-design
    A:error-handling
    and removed
    A:error-unhelpful
    on Oct 2, 2025
  5. kronberger-droid commented on Nov 13, 2026

    @kronberger-droid
    Contributor

    Operator type errors got reworked in #14429.
    $val + $var and $var + $val highlight both operands and the operator in the same way now.

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

    A:error-handlingcategory:inconsistent-behaviorpolishstatus:needs-design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions