版本发布 8
- Deprecated try/catch statement Compiler/Type System: - Fixed uninitialised variables not being propagated as nil Runtime: - Fixed further instances of `dumpvar` and `exportvar`'s quoted strings not escaping invalid UTF-8 - Fixed io library functions throwing a C++ exception when provided with invalid UTF-8 - Fixed bigint.gcd infinitely looping or crashing with some inputs - Fixed cat.encode asserting or crashing when provided with non-table value For Integrators: - `PLUTO_NO_FILESYSTEM` now also disables $include - Fixed `noexcept` being present in lua.h
- Added postfix ++ operator - Added \*\* as an integer exponentiation operator (this previously was a deprecated alias for ^) - Added `protected` class fields - Added `$object` syntax for table creation - Added `$include` - Added `$haltcompiler` - Trailing commas are now allowed for arguments, parameters, and destructuring - String interpolation now implicitly calls `tostring` on each interpolation value - Deprecated the optional 'global' keyword - Deprecated reassignment of for loop control variables in preparation for Lua 5.5 - Removed the deprecated `<constexpr>` attribute Type System: - Added `any` and `nil` type hints - Added type hinting for multiple return values - Added complex type hinting for tables to specify fields - Type hints for `function` type can now also specify the parameters and returns - Added `$type` syntax for named types (this replaces the constexpr call `$type(x)`) - Added `$declare` to set the type of a global - Added `$getproptype` to query the parser's idea of a variable's type Standard Library: - Global & Base - `dumpvar`'s output now includes metatable `__name` where applicable - Bigint - Added bigint.abs, bigint.gcd, bigint.isprobableprime, bigint.export, bigint.import - Added __unm metamethod to bigints - Bigint operations now accept plain Lua ints as operands - Crypto - Added curve25519 to crypto.generatekeypair - Added crypto.hmac, crypto.fnv1a32, crypto.x25519, crypto.derive - Added RSA OAEP modes to crypto.encrypt & crypto.decrypt (rsa-sha1, rsa-sha256, rsa-sha384, rsa-sha512) - Added optional offset parameter to crypto.decompress - Removed previously-deprecated crypto.hexstream - FFI - Added ffi.callback - IO - Added io.unique, io.symlink - Removed previously-deprecated io.copyto - JSON - Added MessagePack support to json.encode and json.decode - Math - Added math.trunc, math.cbrt, math.hypot - Added `math.inf` as an alias for `math.huge` - OS - Added os.dnsresolve - Socket - Added alpn option to socket.starttls - Added early_data option to client-side socket.starttls - String - Added string.span - Removed previously-deprecated string.find_first_of, string.find_first_not_of, string.find_last_of, string.find_last_not_of, string.lfind - Table - Added table.create - Added table.clone - UTF8 - utf8.offset now also returns the final position of the codepoint For Integrators: - Pulled `luaL_openselectedlibs` from Lua 5.5 so you can now define which Lua and Pluto libraries to load globally + preloaded via bitflags. `luaL_openlibs` is now a macro using this function to the same effect as before.
- Improved implicit-global coverage for multiple assignments within the same statement - Fixed preprocessor aliases not taking multi-token arguments (e.g. function calls) - Fixed compile-time concatenation shadowing optional parentheses - Fixed `extends` not inheriting `__pairs` Standard Library: - socket.bind now returns the created coroutine and errors are raised to the caller instead of the scheduler - Fixed socket.listen/socket.bind not failing for bound TCP ports on Windows - Fixed `os.sleep(1)` taking considerably longer than 1ms on Windows - Fixed `scheduler:run` yielding after the final tick - Fixed `dumpvar` and `exportvar`'s quoted strings not escaping bytes that would make it invalid UTF-8 - Fixed filesystem errors on Windows not being UTF-8 encoded when the user has a non-English locale You can view the full commit log [here](https://github.com/PlutoLang/Pluto/compare/0.11.0...0.11.1).
- Improved error message when `new` is provided with a nil value - Fixed ternary expression sometimes picking a bad register - Fixed possible buffer overflow when processing comments Standard Library: - json.encode now errors when provided with a non-finite number such as NaN or infinity - Fixed a rare crash with json.encode
- Compile-Time Evaluation: `io.contents` and `type` are now also available - Compile-Time Evaluation: Table return type is now supported (for functions like `url.parse`) - Improved handling when a C++ exception is thrown during ffi.call - Fixed not inferring that a keyword should be disabled when used as a global variable - For Integrators: Added `PLUTO_PARANOID_KEYWORD_DETECTION` to make this more aggressive - Fixed infinite loop when switch control value contains `or` or `and` - Fixed base32.decode not working correctly on some ARM systems
- Added io.mkdir as an alias for io.makedir - Added io.mkdirs as an alias for io.makedirs - Fixed class preparsing issues with 'switch' & 'do' statements - Fixed not being able to use reserved identifiers with colon call syntax
- Compatibility: Fixed not inferring that a keyword should be disabled from parameter - Universal Block Opener: Fixed `do` not being accepted instead of `then` for `catch` and `$if` - FFI library: Improved cdef parsing and error reporting - Crypto library: Fixed returning incorrect hex digest for MD5 in some cases - Socket library: Fixed an issue where the remote closing a connection too soon could cause recv/peek to never see some data that was sent
- Added chained comparisons (e.g. `1 <= i <= #t`) - Added private methods to classes - Private fields (and methods) can be declared and accessed anywhere inside the class now. Previously, you needed to define a private field *before* you accessed it. This is no longer a restriction. - Pluto now automatically detects if non-compatible keywords should be enabled or disabled based on usage - This is overwritten by the scripter using `pluto_use` or the integrator or user managing compatibility mode, so it only applies when absolutely zero configuration has been applied. This is a significant improvement for lua source code compatibility. - `do` can now be used instead of `then` and `begin` - `if` expressions are now no longer deprecated but require an `end` (e.g. `print(if a then b else c end)`) - `$define` statement now requires an assignment - Fixed handling when an invalid RSA private key is passed to crypto.encrypt, crypto.decrypt, crypto.sign - Fixed not being able to load Lua C modules on Linux - For simplicity in this regard, Pluto now always uses the C ABI to export `lua_` functions and the C++ ABI for `pluto_` functions. Standard library: - Added canvas library - Added ffi library - Added regex library - Added assert.contains - Added bigint.eq, bigint.lt, & bigint.le - Added crypto.ripemd160 - Added crypto.exportkey & crypto.importkey - Added crypto.decompress - Added string.tohex & string.fromhex - Added table.findindex/findkey, table.back, table.keys, table.modget, table.modset, table.slice, table.countvalues, & table.chunk - Added socket.getpeer, socket.peek, socket.getside, socket.istls, & socket.isopen - Added optional limit argument to string.split - Added io.cwd and io.chdir as aliases for io.currentdir - socket.starttls can now be used on server sockets - Optimized json.encode with `__order`