diff --git a/src/build/mod.rs b/src/build/mod.rs index 19e6a22..9ff2c61 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -106,7 +106,6 @@ pub struct FileBuilder<'a> { import_path: &'a Vec, validate_mode: bool, pub assert_collector: AssertCollector, - strict: bool, scope: Scope, import_registry: ImporterRegistry, // NOTE(jwall): We use interior mutability here because we need @@ -176,7 +175,6 @@ impl<'a> FileBuilder<'a> { failures: String::new(), }, scope: scope, - strict: true, import_registry: ImporterRegistry::make_registry(), assets: cache, out_lock: None, @@ -197,7 +195,6 @@ impl<'a> FileBuilder<'a> { summary: String::new(), failures: String::new(), }, - strict: true, assets: self.assets.clone(), // This is admittedly a little wasteful but we can live with it for now. import_registry: ImporterRegistry::make_registry(), @@ -252,7 +249,7 @@ impl<'a> FileBuilder<'a> { } pub fn set_strict(&mut self, to: bool) { - self.strict = to; + self.scope.strict = to; } fn eval_tuple( diff --git a/src/build/scope.rs b/src/build/scope.rs index fcefd92..ddd5356 100644 --- a/src/build/scope.rs +++ b/src/build/scope.rs @@ -40,6 +40,7 @@ pub struct Scope { pub curr_val: Option>, pub build_output: ValueMap, pub search_curr_val: bool, + pub strict: bool, } impl Scope { @@ -53,9 +54,15 @@ impl Scope { curr_val: None, build_output: HashMap::new(), 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 { self.search_curr_val = true; self @@ -71,6 +78,7 @@ impl Scope { curr_val: None, build_output: self.build_output.clone(), search_curr_val: false, + strict: self.strict, } } @@ -82,6 +90,7 @@ impl Scope { curr_val: None, build_output: HashMap::new(), search_curr_val: false, + strict: self.strict, } } @@ -140,6 +149,9 @@ impl Scope { 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) { Ok(v) => return Some(v),