additional fixes in tuple and dict patterns

This commit is contained in:
Scott Richmond 2025-06-22 23:58:55 -04:00
parent bf97a34771
commit f9e4b4623b
2 changed files with 5 additions and 3 deletions

View File

@ -1,12 +1,14 @@
let command = (:forward, 100)
let command = [:forward, 100]
match command with {
(:goto, (x, y)) -> "goto: {x} and {y}"
[:one, :two] -> :no
(:home) -> "go home!"
& (:clear) -> "clear the screen"
& (:right, turns) -> "make {turns} to the right"
& (:left, turns) -> "turn left! by {turns}"
(:forward, steps) -> "forward {steps} turtle paces"
(:back, steps) -> "flip it and reverse it {steps}"
[...xs] -> :splatted
}

View File

@ -662,7 +662,7 @@ impl<'a> Compiler<'a> {
let jump_idx = self.stub_jump(Op::Jump);
for idx in jump_idxes {
self.patch_jump(idx, self.len() - idx - 2)
self.patch_jump(idx, self.len() - idx - 3)
}
self.emit_op(Op::PopN);
@ -736,7 +736,7 @@ impl<'a> Compiler<'a> {
let jump_idx = self.stub_jump(Op::Jump);
for idx in jump_idxes {
self.patch_jump(idx, self.len() - idx - 2);
self.patch_jump(idx, self.len() - idx - 3);
}
self.emit_op(Op::PopN);