Fix parse of def with paren params (#8490)

# Description

This adds back support for parens around params, eg `def foo (x: int) {
... }`

# User-Facing Changes

returns to the original support before the recent parser refactor

# 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` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
This commit is contained in:
JT
2023-03-17 09:08:41 +13:00
committed by GitHub
parent 1b2916988e
commit 0903a891e4
2 changed files with 16 additions and 1 deletions

View File

@ -197,3 +197,15 @@ param: list = [one]
assert!(actual.out.contains(r#"["one"]"#));
})
}
#[test]
fn def_with_paren_params() {
let actual = nu!(
cwd: ".", pipeline(
r#"
def foo (x: int, y: int) { $x + $y }; foo 1 2
"#
));
assert_eq!(actual.out, "3");
}