mirror of
https://github.com/nushell/nushell.git
synced 2024-11-24 17:34:00 +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'('])
|
||||
{
|
||||
signature_pos = Some(pos);
|
||||
break;
|
||||
}
|
||||
|
||||
pos += 1;
|
||||
|
@ -103,10 +103,10 @@ fn parse_file_relative_to_parsed_file_simple() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn predecl_signature_parse() {
|
||||
Playground::setup("predecl_signature_parse", |dirs, sandbox| {
|
||||
fn predecl_signature_single_inp_out_type() {
|
||||
Playground::setup("predecl_signature_single_inp_out_type", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"spam.nu",
|
||||
"spam1.nu",
|
||||
"
|
||||
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");
|
||||
})
|
||||
}
|
||||
|
||||
#[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]
|
||||
#[test]
|
||||
fn parse_file_relative_to_parsed_file() {
|
||||
|
Loading…
Reference in New Issue
Block a user