1
0
mirror of https://github.com/nushell/nushell.git synced 2025-03-29 00:56:45 +01:00

Lex whitespace in input-output types. ()

# Description
Fixes .

# User-Facing Changes


Multiple input-output types can break across lines like command params.

# Tests + Formatting

 E2E parser tests
This commit is contained in:
Texas Toland 2024-04-10 09:28:54 -05:00 committed by GitHub
parent 18ddf95d44
commit 83674909f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 4 deletions
crates/nu-parser/src
src/tests

View File

@ -3041,7 +3041,8 @@ pub fn parse_input_output_types(
full_span.end -= 1;
}
let (tokens, parse_error) = lex_signature(bytes, full_span.start, &[b','], &[], true);
let (tokens, parse_error) =
lex_signature(bytes, full_span.start, &[b'\n', b'\r', b','], &[], true);
if let Some(parse_error) = parse_error {
working_set.parse_errors.push(parse_error);

View File

@ -657,12 +657,41 @@ fn let_variable_disallows_completer() -> TestResult {
}
#[test]
fn def_with_input_output_1() -> TestResult {
fn def_with_input_output() -> TestResult {
run_test(r#"def foo []: nothing -> int { 3 }; foo"#, "3")
}
#[test]
fn def_with_input_output_2() -> TestResult {
fn def_with_input_output_with_line_breaks() -> TestResult {
run_test(
r#"def foo []: [
nothing -> int
] { 3 }; foo"#,
"3",
)
}
#[test]
fn def_with_multi_input_output_with_line_breaks() -> TestResult {
run_test(
r#"def foo []: [
nothing -> int
string -> int
] { 3 }; foo"#,
"3",
)
}
#[test]
fn def_with_multi_input_output_without_commas() -> TestResult {
run_test(
r#"def foo []: [nothing -> int string -> int] { 3 }; foo"#,
"3",
)
}
#[test]
fn def_with_multi_input_output_called_with_first_sig() -> TestResult {
run_test(
r#"def foo []: [int -> int, string -> int] { 3 }; 10 | foo"#,
"3",
@ -670,7 +699,7 @@ fn def_with_input_output_2() -> TestResult {
}
#[test]
fn def_with_input_output_3() -> TestResult {
fn def_with_multi_input_output_called_with_second_sig() -> TestResult {
run_test(
r#"def foo []: [int -> int, string -> int] { 3 }; "bob" | foo"#,
"3",