v1.0.2
More tests, more (compiler) bugs fixed. Damn compiler will be the death of me yet...
In addition to the inevitable compiler bugs I also fixed the way the VM handles upvalues. Before I was giving each
closure its own copy of each upvalue, so multiple closures never properly shared values. This change fixes several
subtle (and several not so subtle) bugs.
Oh, and pcall
works now (it didn't work at all before. Sorry, I never used it).
- Added more script tests. I still have a lot more to do... (script_test.go)
- Fixed incorrect compilation of method declarations (
function a:x() end
). Depressingly the issue was only one
incorrect word, but it resulted in very wrong results (I am really starting to remember why I hated writing the
compiler, the VM was fun, the compiler... not.) (ast/parse.go) - Parenthesized expression that would normally (without the parenthesis) return multiple values (for example:
(...)
)
were not properly truncating the result to a single value. (compile_expr.go) - Fixed a semi-major VM issue with upvalues. Closures that should have a single shared upvalue were instead each using
their own private copy after said upvalue was closed. This required an almost total rewrite of the way upvalues are
stored internally. (all over the place, but mainly callframe.go, function.go, api.go, and vm.go) - JMP instructions created by
break
andcontinue
statements are now properly patched by the compiler to close any
upvalues there may be. (compile.go) - Fixed the
pcall
script function so it actually works. (lmodbase/functions.go) - On a recovered error each stack frame's upvalues are closed before the stack is stripped. This corrects incorrect
behavior that arises when a function stores a closure to an unclosed upvalue then errors out (the closure may still be
referenced, but it's upvalues may be invalid). (api.go, callframe.go)