Fix missing required overlay error (#15058)

# Description
Fixes: #15049

The error occurs when using an alias with a module prefix, it can
initially pass through alias checking, but if the alias leads to
commands which have side effects, it doesn't call these functions to
apply side effects.
This pr ensure that in such cases, nushell still calls
`parse_overlay_xxx` functions to apply the side effects.

I want to make my test easier to write, so this pr depends on
https://github.com/nushell/nushell/pull/15054.

# User-Facing Changes
The following code will no longer raise an error:
```
module inner {}
module spam { export alias b = overlay use inner }
use spam
spam b
```

# Tests + Formatting
Added 2 tests.

# After Submitting
NaN
This commit is contained in:
Wind
2025-02-10 16:27:50 +08:00
committed by GitHub
parent d4675d9138
commit 7d7dbd8b2c
2 changed files with 63 additions and 0 deletions

View File

@ -1287,6 +1287,44 @@ fn alias_overlay_use() {
assert_eq!(actual_repl.out, "foo");
}
#[test]
fn alias_overlay_use_2() {
let inp = &[
"module inner {}",
"module spam { export alias b = overlay use inner }",
"use spam",
"spam b",
"overlay list | get 1",
];
let actual = nu!(&inp.join("; "));
let actual_repl = nu!(nu_repl_code(inp));
assert!(actual.err.is_empty());
assert!(actual_repl.err.is_empty());
assert_eq!(actual.out, "inner");
assert_eq!(actual_repl.out, "inner");
}
#[test]
fn alias_overlay_use_3() {
let inp = &[
"module inner {}",
"module spam { export alias b = overlay use inner }",
"use spam b",
"b",
"overlay list | get 1",
];
let actual = nu!(&inp.join("; "));
let actual_repl = nu!(nu_repl_code(inp));
assert!(actual.err.is_empty());
assert!(actual_repl.err.is_empty());
assert_eq!(actual.out, "inner");
assert_eq!(actual_repl.out, "inner");
}
#[test]
fn alias_overlay_new() {
let inp = &[