mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 09:53:43 +01:00
Add proper shadowing (#2851)
This commit is contained in:
parent
fc44df1e45
commit
27fe356214
@ -89,7 +89,9 @@ impl Scope {
|
||||
|
||||
for frame in self.frames.lock().iter().rev() {
|
||||
for v in frame.vars.iter() {
|
||||
output.insert(v.0.clone(), v.1.clone());
|
||||
if !output.contains_key(v.0) {
|
||||
output.insert(v.0.clone(), v.1.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +104,9 @@ impl Scope {
|
||||
|
||||
for frame in self.frames.lock().iter().rev() {
|
||||
for v in frame.env.iter() {
|
||||
output.insert(v.0.clone(), v.1.clone());
|
||||
if !output.contains_key(v.0) {
|
||||
output.insert(v.0.clone(), v.1.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -455,6 +455,28 @@ fn set_env_doesnt_leak() {
|
||||
assert!(actual.err.contains("did you mean"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn proper_shadow_set_env_aliases() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
set-env DEBUG = true; echo $nu.env.DEBUG | autoview; do { set-env DEBUG = false; echo $nu.env.DEBUG } | autoview; echo $nu.env.DEBUG
|
||||
"#
|
||||
);
|
||||
assert_eq!(actual.out, "truefalsetrue");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn proper_shadow_set_aliases() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
set DEBUG = false; echo $DEBUG | autoview; do { set DEBUG = true; echo $DEBUG } | autoview; echo $DEBUG
|
||||
"#
|
||||
);
|
||||
assert_eq!(actual.out, "falsetruefalse");
|
||||
}
|
||||
|
||||
#[cfg(feature = "which")]
|
||||
#[test]
|
||||
fn argument_invocation_reports_errors() {
|
||||
|
Loading…
Reference in New Issue
Block a user