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:
Adam Joseph 2023-12-12 02:59:19 -08:00 committed by clbot
parent 2949ee08f1
commit 990c4e727f

View file

@ -538,8 +538,15 @@ 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()),
@ -554,6 +561,7 @@ impl<'o> VM<'o> {
} }
} }
} }
}
OpCode::OpJumpIfFalse(JumpOffset(offset)) => { OpCode::OpJumpIfFalse(JumpOffset(offset)) => {
debug_assert!(offset != 0); debug_assert!(offset != 0);