Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow mut to be used with pipelines #9634

Closed
wants to merge 2 commits into from

Conversation

amtoine
Copy link
Member

@amtoine amtoine commented Jul 9, 2023

related to

Description

this PR aims at solving the following error with mut:

> mut a = ls | get name
Error: nu::parser::unexpected_keyword

  × mut statement used in pipeline.
   ╭─[entry #1:1:1]
 1  mut a = ls | get name
   · ─┬─
   ·  ╰── 'mut' in pipeline
   ╰────
  help: Assigning 'ls' to 'a' does not produce a value to be piped. If the pipeline result is meant to be assigned to 'a',
        use 'mut a = (ls | ...)'.

⚠️ TODO: modify the parser as in https://github.com/nushell/nushell/pull/9589/files

User-Facing Changes

users should now be able to use mut without ().

Tests + Formatting

  • 🟢 toolkit fmt
  • 🟢 toolkit clippy
  • toolkit test
  • toolkit test stdlib

After Submitting

sophiajt added a commit that referenced this pull request Jul 11, 2023
# Description

This extends the syntax fix for `let` (#9589) to `mut` as well.

Example: `mut x = "hello world" | str length; print $x`

closes #9634

# User-Facing Changes

`mut` now joins `let` in being able to be assigned from a pipeline

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the
standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
@amtoine amtoine deleted the mut-with-pipeline branch July 12, 2023 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant