mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
FIX: Handle binding and named field collisions in lookups.
This commit is contained in:
parent
207a08d112
commit
5c2d8662bf
@ -67,4 +67,15 @@ let idx = 1;
|
|||||||
assert {
|
assert {
|
||||||
ok = list.(idx) == 2,
|
ok = list.(idx) == 2,
|
||||||
desc = "expected 2, got @" % (list.(idx)),
|
desc = "expected 2, got @" % (list.(idx)),
|
||||||
|
};
|
||||||
|
|
||||||
|
let repeated = {
|
||||||
|
inner = {
|
||||||
|
repeated = "foo",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
assert {
|
||||||
|
ok = repeated.inner.repeated == "foo",
|
||||||
|
desc = "selectors don't jump the line",
|
||||||
};
|
};
|
@ -126,24 +126,30 @@ impl Scope {
|
|||||||
if &sym.val == "self" && is_symbol {
|
if &sym.val == "self" && is_symbol {
|
||||||
return self.curr_val.clone();
|
return self.curr_val.clone();
|
||||||
}
|
}
|
||||||
if self.build_output.contains_key(sym) {
|
|
||||||
return Some(self.build_output[sym].clone());
|
|
||||||
}
|
|
||||||
if self.search_curr_val && self.curr_val.is_some() {
|
if self.search_curr_val && self.curr_val.is_some() {
|
||||||
return match self.curr_val.as_ref().unwrap().as_ref() {
|
match self.curr_val.as_ref().unwrap().as_ref() {
|
||||||
&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) => Some(v),
|
Ok(v) => return Some(v),
|
||||||
Err(_) => None,
|
Err(_) => {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
},
|
},
|
||||||
&Val::List(ref fs) => {
|
&Val::List(ref fs) => {
|
||||||
match Self::lookup_in_list(&sym.pos, &Val::Str(sym.val.clone()), fs) {
|
match Self::lookup_in_list(&sym.pos, &Val::Str(sym.val.clone()), fs) {
|
||||||
Ok(v) => Some(v),
|
Ok(v) => return Some(v),
|
||||||
Err(_) => None,
|
Err(_) => {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if self.build_output.contains_key(sym) {
|
||||||
|
return Some(self.build_output[sym].clone());
|
||||||
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ assert asserts.equal{
|
|||||||
right="TODO description",
|
right="TODO description",
|
||||||
};
|
};
|
||||||
|
|
||||||
let bad_ok_result = t.asserts.ok{
|
let bad_ok_result = asserts.ok{
|
||||||
test=false,
|
test=false,
|
||||||
};
|
};
|
||||||
assert asserts.equal{
|
assert asserts.equal{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user