From 805c1870ee70f9a3263bca9d8c25e56b577d596f Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 1 Sep 2022 17:24:28 +0300 Subject: feat(tvix/eval): track source spans for `or` operator This one is tricky, specifically the span used for the final jump. I decided that it makes sense to use the attrpath node, as the final jump is the one that jumps *over* the default value, so the effect of this is more closely related to the selector than the default. It might be more correct to pass through the `or` token itself and point to this for the jumps, but it depends a bit on what shape of errors we could end up producing from this. Change-Id: I29fbc97ba6b9e14e1a0e5f3a7759ddc299dd9c0c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6390 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/compiler/mod.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'tvix') diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index e5bf0992b1dd..5e9131bf6263 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -584,15 +584,12 @@ impl Compiler<'_> { let mut jumps = vec![]; for fragment in path.attrs() { - self.compile_attr(slot, fragment); - self.push_op_old(OpCode::OpAttrsTrySelect); - jumps.push( - self.chunk() - .push_op_old(OpCode::OpJumpIfNotFound(JumpOffset(0))), - ); + self.compile_attr(slot, fragment.clone()); + self.push_op(OpCode::OpAttrsTrySelect, &fragment); + jumps.push(self.push_op(OpCode::OpJumpIfNotFound(JumpOffset(0)), &fragment)); } - let final_jump = self.push_op_old(OpCode::OpJump(JumpOffset(0))); + let final_jump = self.push_op(OpCode::OpJump(JumpOffset(0)), &path); for jump in jumps { self.patch_jump(jump); -- cgit 1.4.1