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 <sternenseemann@systemli.org>
This commit is contained in:
Vincent Ambo 2022-09-01 17:24:28 +03:00 committed by tazjin
parent 2b1468dde3
commit 805c1870ee

View file

@ -584,15 +584,12 @@ impl Compiler<'_> {
let mut jumps = vec![]; let mut jumps = vec![];
for fragment in path.attrs() { for fragment in path.attrs() {
self.compile_attr(slot, fragment); self.compile_attr(slot, fragment.clone());
self.push_op_old(OpCode::OpAttrsTrySelect); self.push_op(OpCode::OpAttrsTrySelect, &fragment);
jumps.push( jumps.push(self.push_op(OpCode::OpJumpIfNotFound(JumpOffset(0)), &fragment));
self.chunk()
.push_op_old(OpCode::OpJumpIfNotFound(JumpOffset(0))),
);
} }
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 { for jump in jumps {
self.patch_jump(jump); self.patch_jump(jump);