Hi,
The "real" free-variable feature introduced on 3.0 is very cool!
But there's a little bug which can be easily fixed:
Reproduce:
sq> local k=0; function foo() { k-=10; print(k) }
sq> foo()
10
sq> foo()
0
sq> foo()
10
sq> foo()
0
Suggested patch:
at EmitCompoundArith(), sqcompiler.cpp line 357:
(before)
_fs->AddInstruction(ChooseArithOpByToken(tok), tmp, tmp, val, 0);
(fix)
_fs->AddInstruction(ChooseArithOpByToken(tok), tmp, val, tmp, 0);
You can just switch arg1 and arg2 for arith op.
test:
sq> local k=0; function foo() { k-=10; print(k) }
sq> foo()
-10
sq> foo()
-20
sq> foo()
-30
sq> foo()
-40
Tested with '/=', '%=' also without problem.
I hope this helpful.
Thanks.