diff --git a/crates/nu-command/tests/commands/alias.rs b/crates/nu-command/tests/commands/alias.rs index 03df53ae42..9711225f9c 100644 --- a/crates/nu-command/tests/commands/alias.rs +++ b/crates/nu-command/tests/commands/alias.rs @@ -163,3 +163,9 @@ fn alias_default_help() { let first_help_line = actual.out.lines().next().unwrap(); assert!(first_help_line.starts_with("Alias for `echo 'I am a beautiful teapot'`")); } + +#[test] +fn export_alias_with_overlay_use_works() { + let actual = nu!("export alias teapot = overlay use"); + assert!(actual.err.is_empty()) +} diff --git a/crates/nu-parser/src/parse_keywords.rs b/crates/nu-parser/src/parse_keywords.rs index 5eb845523a..057443c141 100644 --- a/crates/nu-parser/src/parse_keywords.rs +++ b/crates/nu-parser/src/parse_keywords.rs @@ -1147,6 +1147,7 @@ pub fn parse_export_in_block( } if let Some(decl_id) = working_set.find_decl(full_name.as_bytes()) { + let starting_error_count = working_set.parse_errors.len(); let ParsedInternalCall { call, output, .. } = parse_internal_call( working_set, if full_name == "export" { @@ -1161,12 +1162,12 @@ pub fn parse_export_in_block( }, decl_id, ); + // don't need errors generated by parse_internal_call + // further error will be generated by detail `parse_xxx` function. + working_set.parse_errors.truncate(starting_error_count); let decl = working_set.get_decl(decl_id); - - let starting_error_count = working_set.parse_errors.len(); check_call(working_set, call_span, &decl.signature(), &call); - let Ok(is_help) = has_flag_const(working_set, &call, "help") else { return garbage_pipeline(working_set, &lite_command.parts); };