mirror of
https://github.com/nushell/nushell.git
synced 2025-03-29 00:56:45 +01:00
Lex whitespace in input-output types. (#12339)
# Description Fixes #12264. # User-Facing Changes Multiple input-output types can break across lines like command params. # Tests + Formatting ✅ E2E parser tests
This commit is contained in:
parent
18ddf95d44
commit
83674909f1
@ -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);
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user