FIX: Bug in dot_lookups

curr_val forms the basis of the scope search but it shouldn't be part of the
lookup expression for the field.
This commit is contained in:
Jeremy Wall 2019-04-18 17:36:16 -05:00
parent 7846c631d0
commit 1fbd1c0a50
2 changed files with 11 additions and 1 deletions

View File

@ -60,4 +60,11 @@ assert t.ok{
assert t.not_ok{
test = foo_check({bar="foo"}),
desc = "we can check for absent foo string fields",
};
let test_for_field = func(name, tpl) => (name) in tpl;
assert t.ok{
test = test_for_field("name", {name="foo"}),
desc = "bareword collisions with field names still works for `in` operator",
};

View File

@ -852,7 +852,10 @@ impl<'a> FileBuilder<'a> {
scope.lookup_idx(right.pos(), &Val::Int(i.val))
}
_ => {
let val = self.eval_expr(right, &scope)?;
// We need to clear any curr_vals for the eval so we don't include them
// in the scope for dot lookups.
let eval_scope = scope.spawn_child();
let val = self.eval_expr(right, &eval_scope)?;
match val.as_ref() {
Val::Int(i) => scope.lookup_idx(right.pos(), &Val::Int(*i)),
Val::Str(ref s) => scope