From 5b05405618f9f38d8dfca39a6dbbc9ce5276c94e Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 15 Jan 2019 18:51:35 -0600 Subject: [PATCH] FIX: presence checks for tuples with NULL values works now. --- integration_tests/comparisons_test.ucg | 5 +++++ src/build/mod.rs | 3 +++ src/build/scope.rs | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/integration_tests/comparisons_test.ucg b/integration_tests/comparisons_test.ucg index 9ded6c3..c7dac8c 100644 --- a/integration_tests/comparisons_test.ucg +++ b/integration_tests/comparisons_test.ucg @@ -178,4 +178,9 @@ assert { assert { ok = NULL != "string", desc = "Strings are comparable to null", +}; + +assert { + ok = (foo in {foo = NULL}), + desc = "Null valued fields are still present in tuple", }; \ No newline at end of file diff --git a/src/build/mod.rs b/src/build/mod.rs index 48aade6..03ca4f9 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -780,6 +780,7 @@ impl<'a> FileBuilder<'a> { Expression::Copy(_) => return self.eval_expr(right, scope), Expression::Call(_) => return self.eval_expr(right, scope), Expression::Simple(Value::Symbol(ref s)) => { + let scope = scope.clone().use_curr_val(); scope .lookup_sym(s, true) .ok_or(Box::new(error::BuildError::new( @@ -789,6 +790,7 @@ impl<'a> FileBuilder<'a> { ))) } Expression::Simple(Value::Str(ref s)) => { + let scope = scope.clone().use_curr_val(); scope .lookup_sym(s, false) .ok_or(Box::new(error::BuildError::new( @@ -904,6 +906,7 @@ impl<'a> FileBuilder<'a> { fn eval_binary(&self, def: &BinaryOpDef, scope: &Scope) -> Result, Box> { let kind = &def.kind; if let &BinaryExprType::IN = kind { + // TODO Should we support this operation on strings too? return self.do_element_check(&def.left, &def.right, scope); }; let left = self.eval_expr(&def.left, scope)?; diff --git a/src/build/scope.rs b/src/build/scope.rs index aea6f53..1af30eb 100644 --- a/src/build/scope.rs +++ b/src/build/scope.rs @@ -56,6 +56,11 @@ impl Scope { } } + pub fn use_curr_val(mut self) -> Self { + self.search_curr_val = true; + self + } + /// Spawn a child scope based on the current scope but without the current /// val set. pub fn spawn_child(&self) -> Self {