nushell/crates/nu-parser/src
WindSoilder 9a6a3a731e
support env and mut assignment with if block and match guard (#9650)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->
Fixes: https://github.com/nushell/nushell/issues/9595

So we can do the following in nushell:
```nushell
mut a = 3
$a = if 4 == 3 { 10 } else {20}
```
or
```nushell
$env.BUILD_EXT = match 3 { 1 => { 'yes!' }, _ => { 'no!' } }
```

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# 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.
-->

---------

Co-authored-by: WindSoilder <windsoilder@DESKTOP-R8GRJ1D.localdomain>
2023-07-13 10:55:41 +02:00
..
deparse.rs allow empty string arguments (#9420) 2023-06-13 07:30:30 -05:00
eval.rs Allow duration defaults (#9249) 2023-05-20 08:23:25 -05:00
flatten.rs Avoid blocking when o+e> redirects too much stderr message (#8784) 2023-05-17 17:47:03 -05:00
known_external.rs Document and critically review ShellError variants - Ep. 3 (#8340) 2023-03-06 18:33:09 +01:00
lex.rs allow comment in multiple line pipeline (#9436) 2023-06-15 13:11:42 +02:00
lib.rs Add virtual path abstraction layer (#9245) 2023-05-23 23:48:50 +03:00
lite_parser.rs Let with pipeline (#9589) 2023-07-03 17:45:10 +12:00
parse_keywords.rs allow mut to take pipelines (#9658) 2023-07-12 06:36:34 +12:00
parse_patterns.rs Cut down on unnecessary parsing for SyntaxShape::Any (#9280) 2023-05-25 07:53:57 +12:00
parser_path.rs Add virtual path abstraction layer (#9245) 2023-05-23 23:48:50 +03:00
parser.rs support env and mut assignment with if block and match guard (#9650) 2023-07-13 10:55:41 +02:00
type_check.rs allow tables to have annotations (#9613) 2023-07-07 11:06:09 +02:00