mirror of
https://github.com/nushell/nushell.git
synced 2025-08-19 07:11:29 +02:00
Hiding of environment variables (#362)
* Remember environment variables from previous scope * Re-introduce env var hiding Right now, hiding decls is broken * Re-introduce hidden field of import patterns All tests pass now. * Remove/Address tests TODOs * Fix test typo; Report hiding error * Add a few more tests * Fix wrong expected test result
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use crate::{span, Span};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ImportPatternMember {
|
||||
@@ -17,6 +18,9 @@ pub struct ImportPatternHead {
|
||||
pub struct ImportPattern {
|
||||
pub head: ImportPatternHead,
|
||||
pub members: Vec<ImportPatternMember>,
|
||||
// communicate to eval which decls/aliases were hidden during `parse_hide()` so it does not
|
||||
// interpret these as env var names:
|
||||
pub hidden: HashSet<Vec<u8>>,
|
||||
}
|
||||
|
||||
impl ImportPattern {
|
||||
@@ -37,4 +41,12 @@ impl ImportPattern {
|
||||
|
||||
span(&spans)
|
||||
}
|
||||
|
||||
pub fn with_hidden(self, hidden: HashSet<Vec<u8>>) -> Self {
|
||||
ImportPattern {
|
||||
head: self.head,
|
||||
members: self.members,
|
||||
hidden,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user