mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 01:43:47 +01:00
Fix parsing of signature inp/out types in predecls (#10642)
# Description Fixes https://github.com/nushell/nushell/issues/10605 (again). The loop looking for `[` to determine signature position didn't stop early enough, so it thought the second `[` denoting the inp/out types marks the beginning of the signature. # User-Facing Changes # Tests + Formatting adds a new `predecl_signature_multiple_inp_out_types` test # After Submitting
This commit is contained in:
parent
67b5e1bde9
commit
4efccb2b1c
@ -202,6 +202,7 @@ pub fn parse_def_predecl(working_set: &mut StateWorkingSet, spans: &[Span]) {
|
|||||||
.starts_with(&[b'('])
|
.starts_with(&[b'('])
|
||||||
{
|
{
|
||||||
signature_pos = Some(pos);
|
signature_pos = Some(pos);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos += 1;
|
pos += 1;
|
||||||
|
@ -103,10 +103,10 @@ fn parse_file_relative_to_parsed_file_simple() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn predecl_signature_parse() {
|
fn predecl_signature_single_inp_out_type() {
|
||||||
Playground::setup("predecl_signature_parse", |dirs, sandbox| {
|
Playground::setup("predecl_signature_single_inp_out_type", |dirs, sandbox| {
|
||||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||||
"spam.nu",
|
"spam1.nu",
|
||||||
"
|
"
|
||||||
def main [] { foo }
|
def main [] { foo }
|
||||||
|
|
||||||
@ -114,11 +114,33 @@ fn predecl_signature_parse() {
|
|||||||
",
|
",
|
||||||
)]);
|
)]);
|
||||||
|
|
||||||
let actual = nu!(cwd: dirs.test(), pipeline("nu spam.nu"));
|
let actual = nu!(cwd: dirs.test(), pipeline("nu spam1.nu"));
|
||||||
|
|
||||||
assert_eq!(actual.out, "foo");
|
assert_eq!(actual.out, "foo");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn predecl_signature_multiple_inp_out_types() {
|
||||||
|
Playground::setup(
|
||||||
|
"predecl_signature_multiple_inp_out_types",
|
||||||
|
|dirs, sandbox| {
|
||||||
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||||
|
"spam2.nu",
|
||||||
|
"
|
||||||
|
def main [] { foo }
|
||||||
|
|
||||||
|
def foo []: [nothing -> string, string -> string] { 'foo' }
|
||||||
|
",
|
||||||
|
)]);
|
||||||
|
|
||||||
|
let actual = nu!(cwd: dirs.test(), pipeline("nu spam2.nu"));
|
||||||
|
|
||||||
|
assert_eq!(actual.out, "foo");
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[ignore]
|
#[ignore]
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_file_relative_to_parsed_file() {
|
fn parse_file_relative_to_parsed_file() {
|
||||||
|
Loading…
Reference in New Issue
Block a user