diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/compiler.rs | 6 | ||||
| -rw-r--r-- | src/lib.rs | 29 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/compiler.rs b/src/compiler.rs index 7f0d32d..a7fc30b 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -799,7 +799,11 @@ impl Compiler { if let Some(var) = self.find_variable(&name) { if let Some(op) = op { - add_op(self, block, Op::Copy); + if var.upvalue { + add_op(self, block, Op::ReadUpvalue(var.slot)); + } else { + add_op(self, block, Op::ReadLocal(var.slot)); + } self.expression(block); add_op(self, block, op); } else { @@ -1050,4 +1050,33 @@ a.a <=> 0" simple: "a := 1 // blargh \na += 1 // blargh \n a <=> 2 // HARGH", expressions: "1 + 1 // blargh \n 2 // blargh \n // HARGH \n", ); + + test_multiple!( + assignment_op_regression, + simple_add: " +a := 0 +b := 99999 +a += 1 +a <=> 1 +", + + simple_sub: " +a := 0 +b := 99999 +a -= 1 +a <=> -1 +", + + strange: " +a := 0 +{ + b := 99999 + { + a := 99999 + } + a -= 1 +} +a <=> -1 +", + ); } |
