diff options
author | Vincent Ambo <mail@tazj.in> | 2022-09-01T14·24+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-09-07T19·23+0000 |
commit | 805c1870ee70f9a3263bca9d8c25e56b577d596f (patch) | |
tree | bb9cefb43d6cada28f1d1066ce1ebc4c11532f21 /tvix/eval/src/compiler | |
parent | 2b1468dde39289c0555ab01d9bb7db935041507b (diff) |
feat(tvix/eval): track source spans for `or` operator r/4723
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>
Diffstat (limited to 'tvix/eval/src/compiler')
-rw-r--r-- | tvix/eval/src/compiler/mod.rs | 11 |
1 files changed, 4 insertions, 7 deletions
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); |