feat(tvix/eval): OpAttrsSelect should propagate catchables
Previously, using a catchable as either argument of OpAttrsSelect would result in an unrecoverable error. This commit matches cppnix behavior by propagating the catchable. Change-Id: I4877f4068ec2b823225f185290693c101d0b9c9e Reviewed-on: https://cl.tvl.fyi/c/depot/+/10303 Tested-by: BuildkiteCI Autosubmit: Adam Joseph <adam@westernsemico.com> Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
2949ee08f1
commit
990c4e727f
1 changed files with 19 additions and 11 deletions
|
@ -538,19 +538,27 @@ impl<'o> VM<'o> {
|
||||||
}
|
}
|
||||||
|
|
||||||
OpCode::OpAttrsSelect => {
|
OpCode::OpAttrsSelect => {
|
||||||
let key = self.stack_pop().to_str().with_span(&frame, self)?;
|
let key = self.stack_pop();
|
||||||
let attrs = self.stack_pop().to_attrs().with_span(&frame, self)?;
|
let attrs = self.stack_pop();
|
||||||
|
if key.is_catchable() {
|
||||||
|
self.stack.push(key);
|
||||||
|
} else if attrs.is_catchable() {
|
||||||
|
self.stack.push(attrs);
|
||||||
|
} else {
|
||||||
|
let key = key.to_str().with_span(&frame, self)?;
|
||||||
|
let attrs = attrs.to_attrs().with_span(&frame, self)?;
|
||||||
|
|
||||||
match attrs.select(key.as_str()) {
|
match attrs.select(key.as_str()) {
|
||||||
Some(value) => self.stack.push(value.clone()),
|
Some(value) => self.stack.push(value.clone()),
|
||||||
|
|
||||||
None => {
|
None => {
|
||||||
return frame.error(
|
return frame.error(
|
||||||
self,
|
self,
|
||||||
ErrorKind::AttributeNotFound {
|
ErrorKind::AttributeNotFound {
|
||||||
name: key.as_str().to_string(),
|
name: key.as_str().to_string(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue