Skip to content

where returns no results when passed a block stored in a variable (but each/reduce work as expected) #5547

Closed

Description

@NotTheDr01ds

Describe the bug

where returns no results when passed a variable containing a block. The same block works when passed as a literal. reduce and each, however, work as expected when passed a block in a variable.

How to reproduce

> seq 1 6 | where {|a| $a > 3 }
╭───┬───╮
│ 0 │ 4 │
│ 1 │ 5 │
│ 2 │ 6 │
╰───┴───╯

> let filter = {|a| $a > 3 }
> seq 1 6 | where $filter
# No results

> seq 1 6 | each $filter
╭───┬───────╮
│ 0 │ false │
│ 1 │ false │
│ 2 │ false │
│ 3 │ true  │
│ 4 │ true  │
│ 5 │ true  │
╰───┴───────╯

> let reduction = {|it, acc| $it + $acc }
> seq 1 6 | reduce $reduction
21

Expected behavior

I think I should expect that where will function the same regardless of whether it is passed a literal block or a variable block. If this is a case of parsing vs. evaluation, I can't discern why reduce and each work differently.

Screenshots

No response

Configuration

key value
version 0.62.1
branch
tag
short_commit c047fd4
commit_hash c047fd4
commit_date 2022-05-14 20:09:41 +00:00
build_os linux-x86_64
rust_version rustc 1.60.0 (7737e0b5c 2022-04-04)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.60.0 (d1fd9fe 2022-03-01)
pkg_version 0.62.1
build_time 2022-05-15 13:46:45 -04:00
build_rust_channel release
features default, trash, which, zip
installed_plugins

Additional context

No response

Activity

  1. fdncred commented on Jul 6, 2022

    @fdncred
    Contributor

    I just tried this and it seems to work now.

    > let filter = {|a| $a > 3 }
    > seq 1 6 | where -b $filter
    ╭───┬───╮
    │ 0 │ 4 │
    │ 1 │ 5 │
    │ 2 │ 6 │
    ╰───┴───╯
    
  2. added this to the v0.66.0 milestone on Jul 6, 2022
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

    category:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions