Skip to content

IR: rasing reasonable error when using subexpression with and operator#15623

Merged
WindSoilder merged 4 commits intonushell:mainfrom
WindSoilder:sub_operator_with_and
Apr 25, 2025
Merged

IR: rasing reasonable error when using subexpression with and operator#15623
WindSoilder merged 4 commits intonushell:mainfrom
WindSoilder:sub_operator_with_and

Conversation

@WindSoilder
Copy link
Copy Markdown
Contributor

Description

Fixes: #15510
I think it's introduced by #14653, which changes and/or to match expression.

After looking into compile_match, it's important to collect the value before matching this.

    // Important to collect it first
    builder.push(Instruction::Collect { src_dst: match_reg }.into_spanned(match_expr.span))?;

This pr is going to apply the logic while compiling and/or operation.

User-Facing Changes

The following will raise a reasonable error:

> (nu --testbin cococo false) and true
Error: nu::shell::operator_unsupported_type

  × The 'and' operator does not work on values of type 'string'.
   ╭─[entry #7:1:2]
 1  (nu --testbin cococo false) and true
   ·  ─┬                         ─┬─
   ·                             ╰── does not support 'string'
   ·   ╰── string
   ╰────

Tests + Formatting

Added 1 test.

After Submitting

Maybe need to update doc nushell/nushell.github.io#1876

@WindSoilder WindSoilder changed the title Sub operator with and IR: rasing reasonable error when using subexpression with and operator Apr 23, 2025
@WindSoilder WindSoilder added the notes:fixes Include the release notes summary in the "Bug fixes" section label Apr 24, 2025
Copy link
Copy Markdown
Member

@sholderbach sholderbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for figuring out those failure cases!

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
@WindSoilder WindSoilder merged commit 11cdb94 into nushell:main Apr 25, 2025
16 checks passed
@github-actions github-actions bot added this to the v0.104.0 milestone Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:fixes Include the release notes summary in the "Bug fixes" section

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IR Evaluation Error in Nushell Command Execution

2 participants