mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 01:43:47 +01:00
Fix wrong parsing of signatures in predecl scan (#10637)
This commit is contained in:
parent
eb4fd144eb
commit
67b5e1bde9
@ -31,7 +31,7 @@ use crate::{
|
||||
lite_parser::{lite_parse, LiteCommand, LiteElement},
|
||||
parser::{
|
||||
check_call, check_name, garbage, garbage_pipeline, parse, parse_call, parse_expression,
|
||||
parse_import_pattern, parse_internal_call, parse_multispan_value, parse_signature,
|
||||
parse_full_signature, parse_import_pattern, parse_internal_call, parse_multispan_value,
|
||||
parse_string, parse_value, parse_var_with_opt_type, trim_quotes, ParsedInternalCall,
|
||||
},
|
||||
unescape_unquote_string, Token, TokenContents,
|
||||
@ -228,7 +228,7 @@ pub fn parse_def_predecl(working_set: &mut StateWorkingSet, spans: &[Span]) {
|
||||
// The second time is when we actually parse the body itworking_set.
|
||||
// We can't reuse the first time because the variables that are created during parse_signature
|
||||
// are lost when we exit the scope below.
|
||||
let sig = parse_signature(working_set, spans[signature_pos]);
|
||||
let sig = parse_full_signature(working_set, &spans[signature_pos..]);
|
||||
working_set.parse_errors.truncate(starting_error_count);
|
||||
working_set.exit_scope();
|
||||
|
||||
|
@ -102,6 +102,23 @@ fn parse_file_relative_to_parsed_file_simple() {
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn predecl_signature_parse() {
|
||||
Playground::setup("predecl_signature_parse", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"spam.nu",
|
||||
"
|
||||
def main [] { foo }
|
||||
|
||||
def foo []: nothing -> nothing { print 'foo' }
|
||||
",
|
||||
)]);
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), pipeline("nu spam.nu"));
|
||||
|
||||
assert_eq!(actual.out, "foo");
|
||||
})
|
||||
}
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn parse_file_relative_to_parsed_file() {
|
||||
|
Loading…
Reference in New Issue
Block a user