news-2021-03-29-luau-recap-march-2021.md
March 29, 2021
It’s been a busy month in Luau!
Luau supports variadic functions, meaning ones which can take a variable number of arguments (varargs!) but previously there was no way to specify their type. Now you can!
This function takes a string, plus as many numbers as you like, but if you try calling it with anything else, you’ll get a type error, for example f("oh", true) gives an error “Type boolean could not be converted into number”
Variadics can be used in function declarations, and function types, for example
WARNING Generic functions are currently disabled as we’re fixing some critical bugs.
We’ve made various improvements to the Luau typechecker:
self has type anydebug.* methodsWe are continuing to squeeze the performance out of all sorts of possible code; this is an ongoing process and we have many improvements in the pipeline, big and small. These are the changes that are already live:
math.clamp, math.sign and math.round by 2.3x, 2x and 1.6x respectivelycoroutine.resume with ~10% gains on coroutine-heavy benchmarksnil; this makes some benchmarks 2-3% fastermath.abs or bit32.rrotate are now significantly faster in some cases, e.g. this makes SHA256 benchmark 25% fasterrawset, rawget, rawequal and 2-argument table.insert are now 40-50% faster; notably, table.insert(t, v) is now faster than t[#t+1]=vNote that we work off a set of benchmarks that we consider representative of the wide gamut of code that runs on Luau. If you have code that you think should be running faster, never hesitate to open a feature request / bug report on Roblox Developer Forum!
We continue to improve our Luau debugger and we have added a new feature to help with coroutine call debugging. The call stack that is being displayed while stopped inside a coroutine frame will display the chain of threads that have called it.
Before:
After:
We have restored the ability to break on all errors inside the scripts. This is useful in cases where you need to track the location and state of an error that is triggered inside ‘pcall’. For example, when the error that’s triggered is not the one you expected.
debug.info function which allows retrieving information about stack frames or functions; similarly to debug.getinfo from Lua, this accepts an options string that must consist of characters slnfa; unlike Lua that returns a table, the function returns all requested values one after another to improve performance.Luau now has a shiny new logo!
and/or and IsA!