Skip to content

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

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

WindSoilder merged 4 commits into
nushell: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 Noted in "Bug fixes" section label Apr 24, 2025

@sholderbach sholderbach left a comment

Copy link
Copy Markdown
Member

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!

@WindSoilder
WindSoilder merged commit 11cdb94 into nushell:main Apr 25, 2025
@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 Noted in "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