mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
FIX: env lookups should respect the strict flag.
This commit is contained in:
parent
24aa55fdac
commit
71d4f6f620
@ -106,7 +106,6 @@ pub struct FileBuilder<'a> {
|
|||||||
import_path: &'a Vec<PathBuf>,
|
import_path: &'a Vec<PathBuf>,
|
||||||
validate_mode: bool,
|
validate_mode: bool,
|
||||||
pub assert_collector: AssertCollector,
|
pub assert_collector: AssertCollector,
|
||||||
strict: bool,
|
|
||||||
scope: Scope,
|
scope: Scope,
|
||||||
import_registry: ImporterRegistry,
|
import_registry: ImporterRegistry,
|
||||||
// NOTE(jwall): We use interior mutability here because we need
|
// NOTE(jwall): We use interior mutability here because we need
|
||||||
@ -176,7 +175,6 @@ impl<'a> FileBuilder<'a> {
|
|||||||
failures: String::new(),
|
failures: String::new(),
|
||||||
},
|
},
|
||||||
scope: scope,
|
scope: scope,
|
||||||
strict: true,
|
|
||||||
import_registry: ImporterRegistry::make_registry(),
|
import_registry: ImporterRegistry::make_registry(),
|
||||||
assets: cache,
|
assets: cache,
|
||||||
out_lock: None,
|
out_lock: None,
|
||||||
@ -197,7 +195,6 @@ impl<'a> FileBuilder<'a> {
|
|||||||
summary: String::new(),
|
summary: String::new(),
|
||||||
failures: String::new(),
|
failures: String::new(),
|
||||||
},
|
},
|
||||||
strict: true,
|
|
||||||
assets: self.assets.clone(),
|
assets: self.assets.clone(),
|
||||||
// This is admittedly a little wasteful but we can live with it for now.
|
// This is admittedly a little wasteful but we can live with it for now.
|
||||||
import_registry: ImporterRegistry::make_registry(),
|
import_registry: ImporterRegistry::make_registry(),
|
||||||
@ -252,7 +249,7 @@ impl<'a> FileBuilder<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_strict(&mut self, to: bool) {
|
pub fn set_strict(&mut self, to: bool) {
|
||||||
self.strict = to;
|
self.scope.strict = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_tuple(
|
fn eval_tuple(
|
||||||
|
@ -40,6 +40,7 @@ pub struct Scope {
|
|||||||
pub curr_val: Option<Rc<Val>>,
|
pub curr_val: Option<Rc<Val>>,
|
||||||
pub build_output: ValueMap,
|
pub build_output: ValueMap,
|
||||||
pub search_curr_val: bool,
|
pub search_curr_val: bool,
|
||||||
|
pub strict: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Scope {
|
impl Scope {
|
||||||
@ -53,9 +54,15 @@ impl Scope {
|
|||||||
curr_val: None,
|
curr_val: None,
|
||||||
build_output: HashMap::new(),
|
build_output: HashMap::new(),
|
||||||
search_curr_val: false,
|
search_curr_val: false,
|
||||||
|
strict: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn use_strict(mut self) -> Self {
|
||||||
|
self.strict = true;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn use_curr_val(mut self) -> Self {
|
pub fn use_curr_val(mut self) -> Self {
|
||||||
self.search_curr_val = true;
|
self.search_curr_val = true;
|
||||||
self
|
self
|
||||||
@ -71,6 +78,7 @@ impl Scope {
|
|||||||
curr_val: None,
|
curr_val: None,
|
||||||
build_output: self.build_output.clone(),
|
build_output: self.build_output.clone(),
|
||||||
search_curr_val: false,
|
search_curr_val: false,
|
||||||
|
strict: self.strict,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +90,7 @@ impl Scope {
|
|||||||
curr_val: None,
|
curr_val: None,
|
||||||
build_output: HashMap::new(),
|
build_output: HashMap::new(),
|
||||||
search_curr_val: false,
|
search_curr_val: false,
|
||||||
|
strict: self.strict,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,6 +149,9 @@ impl Scope {
|
|||||||
return Some(Rc::new(Val::Str(val.clone())));
|
return Some(Rc::new(Val::Str(val.clone())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !self.strict {
|
||||||
|
return Some(Rc::new(Val::Empty));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Val::Tuple(ref fs) => match Self::lookup_in_tuple(&sym.pos, &sym.val, fs) {
|
Val::Tuple(ref fs) => match Self::lookup_in_tuple(&sym.pos, &sym.val, fs) {
|
||||||
Ok(v) => return Some(v),
|
Ok(v) => return Some(v),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user