Merge in Luau 0.732 - #88
Merged
Merged
Conversation
Hi there, folks! We're back with another weekly Luau release! # Language * Adds the `const` keyword for defining constant bindings that are statically forbidden to be reassigned to. This implements [luau-lang/rfcs#166](luau-lang/rfcs#166). * Adds a collection of new math constants to Luau's `math` library per [luau-lang/rfcs#169](luau-lang/rfcs#169). # Analysis * Fixes a class of bugs where Luau would not retain reasonable upper or lower bounds on free types, resulting in types snapping to `never` or `unknown` despite having bounds. ```luau --!strict -- `lines` will be inferred to be of `{ string }` now, and prior -- was local lines = {} table.insert(lines, table.concat({}, "")) print(table.concat(lines, "\n")) ``` ```luau --!strict -- `buttons` will be inferred to be of type `{ { a: number } }` local buttons = {} table.insert(buttons, { a = 1 }) table.insert(buttons, { a = 2, b = true }) table.insert(buttons, { a = 3 }) ``` * Disables the type error from `string.format` when called with a dynamically-determined format string (i.e. a non-literal string argument with the type `string`) in response to user feedback about it being too noisy. * Resolves an ICE that could occur when type checking curried generic functions. Fixes #2061! * Fixes false positive type errors from doing equality or inequality against `nil` when indexing from a table * In #2256, adds a state parameter to the `useratom` callback for consistency with other callbacks. # Compiler - Improves the compiler's type inference for vector component access, numerical for loops, function return types and singleton type annotations, fixing #2244 #2235 and #2255. # Native Code Generation - Fixes a bug where some operations on x86_64 would produce integers that would take up more than 32-bits when a 32-bit integer is expected. We resolve these issues by properly truncating to 32-bits in these situations. - Improves dead store elimination for conditional jumps and fastcalls arguments, improving overall native codegen performance by about 2% on average in benchmarks, with some benchmarks as high as 25%. --------- Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
… (#2290)
The following code now generates a Type Error:
```luau
type T = {
read x: number
}
local foo: T = { x = 5 }
foo.x += 5
```
The flag `LuauLValueCompoundAssignmentVisitLhs` has been added, as well
as 1 test.
---------
Co-authored-by: ariel <aweiss@hey.com>
# Analysis * Fix luau-lang/luau#1986 * Fix luau-lang/luau#1890 * Minor bugfixes and improvements # Compiler * Do not constant-fold strings that are longer than 4096 characters. This helps to avoid pathalogical misoptimizations that could result in the compiling bytecode growing very large. * fix constant placement into the CHECK_BUFFER_LEN 'double source' argument --------- Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Ariel Weiss <arielweiss@roblox.com>
Hey folks! Another week another Luau release 🙂
# Analysis
* `InsertionOrderedMap` has been moved from the `Analysis` library to
`Common`.
* Subtyping has been rewritten to avoid extra allocations: there should
be no behavioral change from this effort, only somewhat lower memory
pressure.
* Fixed a bug where analyzing comparing a value that is too complex to
type check against `nil` may cause the type checker to crash.
* `pcall` now handles functions that return no values, for example:
```luau
local mod = require('mymodule')
-- Previously, we would error claiming that we only expect one value on the left-hand-side.
-- Now, there is no error and `result` is typed as `unknown`.
local success, result = pcall(function()
mod.dothething()
end)
```
# Compiler
* Fixed a bug in `const` where function statements were excluded from
const checks. Fixes #2282
```luau
const a = 42
-- The following will now fail to compile.
function a()
end
```
* Table literal "shapes" can now encorporate constant values at bytecode
compile time. We store the shape of constant tables if all their keys
are constants, which allows slightly faster insertion when building said
literals (we can preallocate a table in a particular shape). Now, we can
also store constant values, making construction a single bytecode. For
example:
```luau
-- This snippet ...
return { x = 1, y = 2 }
```
```luau
-- ... used to compile to bytecode like ...
DUPTABLE R0 2
LOADN R1 1
SETTABLEKS R1 R0 K0 ['x']
LOADN R1 2
SETTABLEKS R1 R0 K1 ['y']
RETURN R0 1
```
```luau
-- ... and now compiles to something like ...
DUPTABLE R0 4
RETURN R0 1
```
# Runtime
* Introduced a `@debugnoinline` attribute behind a debug flag. We do not
actively plan to ship this but have added it to help test compiler and
runtime optimizations.
* Fixed a bug where setting a breakpoint in a natively compiled function
could crash on ARM64.
* NCG: The data section of generated code is no longer allocated as
executable, preventing a class of potential exploits.
---
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Ariel Weiss <arielweiss@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com>
Co-authored-by: Ilya Rezvov <irezvov@roblox.com>
Co-authored-by: Tom Schollenberger <tschollenberger@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Karim Mouline <kmouline@roblox.com>
Fixes
```luau
local x: unknown
if type(x) == "vector" then -- Lint warning
local y = x -- `never`
end
```
Adds flags `LuauRefinementTypeVector` and `LuauLinterVectorPrimitive`.
Modified 1 Linter test and 1 refinement test. Adds 1 refinement test.
Another week, another release! Happy spring! 🌷 ### Analysis - Remove an incorrect assertion triggered when we fail to bind a generic pack. - Various miscellaneous fixes for bugs found by the fuzzer. ### Runtime - Fix `DUPTABLE` constant packing not respecting side-effects. - NCG: fix removal of stores that are still needed in VM exits. - NCG: fix a bug that caused buffer access ranges to be computed incorrectly. - Fix #2293. ### Miscellaneous - Various `Makefile` improvements. - Add lldb providers for `Proto`. - Add new `--dump-constants` flag to `luau-compile`. --- Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: David Cope <dcope@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Thomas Schollenberger <tschollenberger@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
… (#2071)
Implements the `read` and `write` property attributes for external type
definitions, which the embedded `vector` type now makes use of:
**Before:**
```luau
declare extern type vector with
x: number
y: number
z: number
end
```
**After:**
```luau
declare extern type vector with
read x: number
read y: number
read z: number
end
```
The following code now creates type-errors in the expected places:
```luau
--!strict
local function increment(v: vector)
v.x += 1 -- TE
v.x -= 1 -- TE
v.y *= 1 -- TE
v.z /= 1 -- TE
print(v.x) -- No TE
print(v.x > 5) -- No TE
v.x = 15 -- TE
end
increment(vector.create(1, 2, 3))
```
This PR also supports different read/write types:
```luau
-- Definition
declare extern type Foo with
read Bar: number
write Bar: string
end
-- Script
local f: Foo
local b: number = f.Bar
f.Bar = "Hello, World!"
```
Additionally,
* Adds two new tests for the implemented syntax
* Adds the `LuauLValueCompoundAssignmentVisitLhs`,
`LuauExternReadWriteAttributes` and `LuauTypeCheckerVectorReadOnly`
flags
Closes #2062
The Luau team has been cooking for this week's release! 🍳 We have implemented an initial version of the [64-bit Integer Type](https://rfcs.luau.org/type-long-integer.html)! Please keep in mind that although the RFC has been accepted, we are currently in the process of identifying and fixing bugs, which may require amending the original RFC. Additionally, we've been working on the following: ### Analysis - Fix crash reported in #2305. - Reword type-function error messages. - Fix various crashes found by fuzzer and in unit tests. - Rework how we track generalizable free types. ### Runtime - NCG: Propagate register tags across block chains. - NCG: Fix a bug in how register information was set up when entering a new block. - NCG: Fix a bug where register tag information for non-live registers was incorrectly propagated. - NCG: Remove duplicate stores of doubles and integers. - NCG: Unconditionally provide tags to read/write functions for buffers. ### Miscellaneous - Various Makefile, lldb_formatter, and lldb-dap improvements. --- Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: David Cope <dcope@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: James McNellis <jmcnellis@roblox.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Thomas Schollenberger <tschollenberger@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com>
Hi everyone! Another week, another release 🌺 🐰
This week we've made some major performance boosts for property
accesses, feature fixes, as well as our regular bug fixes and
improvements!
### Analysis
* `Luau/OverloadResolution.h` has been renamed to
`Luau/OverloadResolver.h` (to match the struct name)
* Added syntax highlighting for the `const` keyword!
* Fixed an internal compiler error that could occur when type checking
erroneous uses of `const`, for example:
```luau
-- This is not a valid `const` declaration as we require that `const` declarations
-- have values, as it is almost certainly a mistake if they don't (as you cannot assign
-- to them later). Previously this _also_ caused an ICE in the new solver, which is not
-- desirable.
const foobar
return foobar
```
* Fixed a bug that could result in function calls failing to type check
due to ungeneralized free types:
```luau
function add(a, b)
return a + b
end
local vec2 = {}
function vec2.new(x, y)
return setmetatable({ x = x or 0, y = y or 0 }, {
__add = function(v1, v2)
return { x = v1.x + v2.x, y = v1.y + v2.y }
end,
})
end
-- Prior, this would fail to type check and we'd get warnings
-- about ungeneralized types (`number <: 'a` isn't a subtype of blah)
local a = add(vec2.new(0, 0), vec2.new(1, 1))
```
* Fixed a bug where `type(x) == "vector"` always refined `x` to `never`:
```luau
local x: unknown
if type(x) == "vector" then
local y = x -- Prior, x would be `never`
end
```
### Compiler & Runtime
* 10-30% performance improvement for Luau userdata property accesses via
new property descriptor bytecode caching
* Increased precision for `math.noise()`
* Fixed a bug where generic `for` loops were incorrectly optimized when
the global environment was modified
```luau
local env = getfenv(1)
env.next = {1, 2, 3}
-- This will now disable `LOP_FORGPREP_NEXT` optimization, and run successfully
local ok, err = pcall(function()
for k, v in next, {} do end
end)
```
* Added 64-bit Integer output to the AST Json Encoder, and fixed some
bugs from the initial implementation
* NCG: fixed an issue where certain fast-call sequences with multiple
return values could cause incorrect register tracking
* NCG: improved compiler performance by caching register tags and
computing them only when consumed by an instruction
### Miscellaneous
* Improved `lldb` debugger support by adding visualization for
`lua_State`, including a new `set_userdata_type_name` method to
configure the debugger for custom `userdata` structures.
--------------------------------------
Thank you to all our contributors this week!
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com>
Co-authored-by: Ilya Rezvov <irezvov@roblox.com>
Co-authored-by: Karl Rehm <krehm@roblox.com>
Co-authored-by: Simone Guggiari <sguggiari@roblox.com>
Co-authored-by: Thomas Schollenberger <tschollenberger@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: @PhoenixWhitefire
---------
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Ariel Weiss <arielweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com>
Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com>
Co-authored-by: Sora Kanosue <skanosue@roblox.com>
Hello folks! Sorry for the late release, but it's another week and another Luau release, though really more of a Luau VM release this time around 🙂 # Runtime * Added `FASTCALL` support for `buffer.writeinteger` and `buffer.readinteger` (#2326) * NCG: Fixed a bug in which `buffer` writes did not invalidate the heap data of buffers. In practice this did not occur due to this codepath mostly incuring a VM exit, but the bug was visible in the IR output. * NCG: Reworked how we track whether IR instructions return values, fixing a class of performance issues (increased register pressure from dead instructions) and potential correctness issues. * NCG: Avoid potentially spilling a register _onto_ the frame pointer on ARM, which could cause unwinding crashes or other issues while debugging. * NCG: Fixed a bug in the NCG integer implementation where optimizing a comparison to an integer would cause us to jump to a nonsense position (the arguments given to `JUMP` were erroneous). * NCG: Fixed a bug where writes to `userdata` would not invalidate the store cache, meaning we may incorrectly assume a read result has not changed. * NCG: Improved how values are passed between function calls on x86, opening up further optimization opportunities by avoiding some register spills. --- Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Thomas Schollenberger <tschollenberger@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Annie Tang <annietang@roblox.com> Co-authored-by: Annie Tang <98965493+annieetang@users.noreply.github.com>
It is new Friday and new Luau release! This release is mostly focused on improving integer support in Luau VM: - NCG integer lowerings for x64 and Arm64 were added by @tommyscholly (HUGE!) - FASTCALL2K support for integers and other integer fastcall fixes - Test coverage for integers was improved Also: - BytecodeGraph representation is introduced for coming Bytecode -> Bytecode inliner and optimizer - Improved type alias resolution - Fix for constraints resolution of MetatableTypes in LValue position Co-authored-by: Andy Friesen [afriesen@roblox.com](mailto:afriesen@roblox.com) Co-authored-by: Ilya Rezvov [irezvov@roblox.com](mailto:irezvov@roblox.com) Co-authored-by: Thomas Schollenberger [tschollenberger@roblox.com](mailto:tschollenberger@roblox.com) Co-authored-by: Vyacheslav Egorov [vegorov@roblox.com](mailto:vegorov@roblox.com) --------- Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Annie Tang <annietang@roblox.com> Co-authored-by: Annie Tang <98965493+annieetang@users.noreply.github.com>
This fixes a discrepancy between string interpolation (<code>local a =
\`{xyz}\`</code>) and the manually written equivilant version (`local a
= ("%*"):format(xyz)`), where string interpolation would sometimes
introduce a `MOVE` even when it didn't need to as the target register
was marked as temporary
<details><summary>Bytecode difference</summary>
Code: <code>local f = \`{global}\`</code>
Before:
```
Function 0 (??):
1: local f = `{global}`
LOADK R1 K0 ['%*']
GETGLOBAL R3 K1 ['global']
NAMECALL R1 R1 K2 ['format']
CALL R1 2 1
MOVE R0 R1
RETURN R0 0
```
After:
```
Function 0 (??):
1: local f = `{global}`
LOADK R0 K0 ['%*']
GETGLOBAL R2 K1 ['global']
NAMECALL R0 R0 K2 ['format']
CALL R0 2 1
RETURN R0 0
```
</details>
This is also technically a performance improvement, though the
difference is mostly unnoticeable in normal contexts (I'm seeing a 4-5%
improvement on a 1e7 loop which is nothing but the optimisable string
interp, so about as good as the case gets)
I've not written a new test case as `InterpStringRegisterCleanup`
already covers the unoptimisable case
This change is gated behind FFlag `LuauRequireResolveAliasNullCheck`. Fixes #2272.
Hello everyone! We have another weekly release of Luau for you with
updates in multiple areas.
### What's New
* Added `lua_registeruserdatadirectfieldget` API to register
fastcall-like handlers for tagged userdata property reads. Without call
frame creation and Luau state interaction, simple values can be fetched
up to 4x faster.
### Analysis
* Fixed an issue where `any` when used as part of a table type was not
correctly suppressing errors. Closes #2341
```luau
type Foo<T> = { kind: "foo", foo: T }
type Bar<T> = { kind: "bar", bar: T }
type FooBar<T> = Foo<T> | Bar<T>
local function f(x: Foo<number>): FooBar<any>
-- This used to error prior, despite the `any` that should allow for error suppression.
return x
end
```
* Fixed one of the frequent cases for internal analysis errors related
to cyclic types
### Compiler
* Added constant propagation for table fields:
```luau
local config = { a = 2, b = 4 }
local function foo(x)
return x * config.a -- config table is not captured and there is no runtime field lookup
end
```
For the optimization to take place, table cannot be directly or
indirectly modified.
We expect that some of the restrictions will get lifted in the future.
### Runtime
* Fixed an issue with `lua_registeruserdatadirectaccess` API when a
`newproxy` object is encountered
### Native Code Generation
* Added native lowering for `buffer.readinteger` and
`buffer.writeinteger`
* Added 'nopPadding' code generation option which inserts nop
instructions to randomize code layout
* Fixed handling of `integer.min/max/clamp` fastcalls which could
produce an incorrect result before
* Fixed buffer read/write operations with constant offsets incorrectly
taking a VM assist when last byte is touched
### Miscellaneous
* luau and luau-compile binaries now accept --codegen-cold option to
natively compile all functions
---
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com>
Co-authored-by: Karim Mouline <kmouline@roblox.com>
Co-authored-by: Sora Kanosue <skanosue@roblox.com>
Co-authored-by: Thomas Schollenberger <tschollenberger@roblox.com>
Co-authored-by: Varun Saini <vsaini@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Howdy there, folks! We've got another Luau release this week, mainly focused on some pain points with type analysis! **Note**: For folks who are using definition files for providing type definitions for the runtime environment they're working in, we also wanted to highlight that the `declare class` syntax is being entirely cleaned up finally. We added syntax for `declare extern type` many months ago, and with the [Luau classes RFC](https://rfcs.luau.org/syntax-classes.html) accepted, it is particularly prudent that we finalize the cleanup of `declare class`. If you're still on the old syntax, please update to use `declare extern type Foo with ...` to avoid interruption when a future release removes `declare class` entirely. ## Language * The `const` keyword now correctly appears in autocomplete suggestions from Luau. ## Analysis - Fixes false positive `OptionalValueAccess` errors when iterating over a table with an optional indexer type. The VM's generalized iteration already guarantees non-nil values in the loop body, and the type checker now reflects that. Fixes [luau-lang/luau#2236](luau-lang/luau#2236). ```luau --!strict type TypeA = { Value: any } local list = {} :: { [string]: TypeA? } for index, a in list do a.Value = 1 -- No longer incorrectly reported as 'TypeA?' could be nil end ``` - Improves bidirectional type inference for unions of tables and functions. Table literals that clearly match one branch of a union are no longer falsely rejected: ```luau --!strict type FnRecord = { handler: (number) -> string, label: string? } type StrRecord = { handler: string, label: string? } type Record = FnRecord | StrRecord -- Previously flagged as not a subtype of `Record`; now correctly accepted as a FnRecord local r: Record = { handler = function(input) return tostring(input) end, label = "test", } ``` - Fixes a crash that could occur when `typeof` is used inside the type arguments of an instantiated method call: ```luau local t = {} function t:f<T>() end local x = 42 t:f<<typeof(x)>>() -- No longer crashes ``` - Fixes missing autocomplete suggestions for string singleton types when the expected type is an intersection containing a string singleton (e.g. `"Foo" & "Foo"` or `keyof<typeof(tbl)> & T`). ## Compiler - Fixes a discrepancy where string interpolation would sometimes emit a redundant `MOVE` instruction that an equivalent `string.format` call would not, when the target register was already correct. (#2324 from @9382, thanks!) ## Internal Contributors Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Annie Tang <annietang@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Thomas Schollenberger <tschollenberger@roblox.com> Co-authored-by: Varun Saini <vsaini@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Annie Tang <annietang@roblox.com> Co-authored-by: Annie Tang <98965493+annieetang@users.noreply.github.com> Co-authored-by: Ilya Rezvov <irezvov@roblox.com>
Hey everyone!
We have a few nice new things to share:
## Language
* Add support for read-only indexers using the syntax `{read T}` or
`{read [K]: V}`. Read-only indexers are really useful for functions that
accept an array, but don't modify it because calls to such a function
can be tested covariantly rather than invariantly:
```luau
function print_them_old(a: {Instance}) ... end
function print_them_new(a: {read Instance}) ... end
local players: {Players} = ...
-- We have to reject this call because, for all we know, the
-- function could insert non-Players into our Player array!
print_them_old(players)
-- This function is not allowed to write to the array so
-- everything is fine.
print_them_new(players)
```
* Fix a unification bug that would result in incorrect inference in
cases like `'a <: T | nil` where `'a` is a free type and `T` is an
instantiated generic. This would result in incorrect inferences in cases
like the following:
```luau
local function f<T>(a: T & string): T
return a
end
local b = f("hello")
local c = f(("world" :: string))
```
* First steps toward implementing classes. See [the
RFC](https://github.com/luau-lang/rfcs/blob/master/docs/syntax-classes.md)
for details.
## Analysis
* Ensure that inferred arguments to functions are instantiated. This
fixes a class of bugs that could cause type inference to hang and
consume lots of memory.
* Improve the error that's reported when two table types are only
incompatible because of a read/write restriction. This fixes cases where
we would report nonsense errors like "number is not a subtype of
number."
* We had an issue where passing a function type through a type function
would cause type inference to discard the data about the parameters'
names even if the type was returned verbatim. This is now fixed.
## Interpreter
* Adjust the FASTCALL3 inlining cost model to line up with other
fastcalls.
* Reduce Luau VM interpreter loop stack pressure in Debug/NoOpt builds
* Optimize the constant folding pass in the compiler
## Native Code Generation
* Introduce ExitSync blocks to help avoid synchronizing the VM stack
unnecessarily.
* NCG VM exit sync cannot include register from blocks not in a chain.
* Add CALLFB instruction and feedback vectors in proto. This will be
used to help the runtime know which function calls can be inlined.
* Handle repeated IrCmd::LOAD_ENV and switch from table RegisterLink
information to SSA info.
## General
* You can now pass `--solver=new` or `--solver=old` to `luau-analyze`
tool to select the solver you'd like to use. It defaults to the new
solver.
## Internal Contributors
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Annie Tang <annietang@roblox.com>
Co-authored-by: Ariel Weiss <arielweiss@roblox.com>
Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com>
Co-authored-by: Ilya Rezvov <irezvov@roblox.com>
Co-authored-by: Sora Kanosue <skanosue@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
---------
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Ariel Weiss <arielweiss@roblox.com>
Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com>
Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com>
Co-authored-by: Sora Kanosue <skanosue@roblox.com>
Co-authored-by: Annie Tang <annietang@roblox.com>
Co-authored-by: Annie Tang <98965493+annieetang@users.noreply.github.com>
Co-authored-by: Ilya Rezvov <irezvov@roblox.com>
The new solver's "Available overloads" follow-up diagnostic gets emitted
without a module name, so downstream consumers see it as coming from an
empty path which breaks paths.
See primary error looking correct but follow ups rendering as junk
relative paths:
```text
Packages/_Index/example_package/src/init.luau:1845.6-1845.85: TypeError: None of the overloads for function that accept 1 arguments are compatible.
../../../../..:1845.6-1845.85: TypeError: Available overloads: <V>({V}, V) -> (); and <V>({V}, number, V) -> ()
```
After fix:
```text
Packages/_Index/example_package/src/init.luau:1845.6-1845.85: TypeError: None of the overloads for function that accept 1 arguments are compatible.
Packages/_Index/example_package/src/init.luau:1845.6-1845.85: TypeError: Available overloads: <V>({V}, V) -> (); and <V>({V}, number, V) -> ()
```
Co-authored-by: haziscool <haziscool@users.noreply.github.com>
Every so often we have some issue that only pops up on GCC or Clang: we default to Clang but we should test with GCC as well.
Hello! A somewhat small set of release notes for this week, but don't
mistake it for being unexciting because ...
## Yielding iterators
Luau now supports yielding within iterators! This affords code patterns
such as being able to iterate over the results of an IO bound operation,
e.g.:
```luau
-- `net.serve` here could return a generator and the requisite initial state,
-- and said generator can now yield to wait for IO!
for request in net.serve(8080) do
request.respondWith("Echo: " .. request.body)
end
```
Note: yielding in metamethods is *still* unsupported, including
`__iter`. Fixes luau-lang/luau#838.
## Ast
* Added concrete syntax tree support for expression groups and type
groups
```luau
-- In the CST, we will now preserve whitespace here ...
local x = (1 + 2 )
-- ... and here ...
type t = (number )
```
## Runtime
* Introduced a new `CMPPROTO` bytecode instruction to be used with
just-in-time bytecode inlining.
* NCG: Fixed a bug where an optimization pass would cause us to treat a
known `nil` value as potentially garbage collected.
---
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Annie Tang <annietang@roblox.com>
Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com>
Co-authored-by: Ilya Rezvov <irezvov@roblox.com>
Co-authored-by: Sora Kanosue <skanosue@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Another week, another release! ### What's new? - Implement export semantics as described in luau-lang/rfcs#179. ### Analysis - Use sentinel `Position`s in the CST rather than `std::optional` to reduce memory pressure. ### Runtime - Compiler: Improve dump output for Luau table constants (e.g. when using `luau-compile`). - NCG: Record block exit info for all blocks. - NCG: Reduce spill pressure by using dead VM register store locations. --- Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: James McNellis <jmcnellis@roblox.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Thomas Schollenberger <tschollenberger@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
This PR fixes a discrepancy between `Ast/include/Luau/PrettyPrinter.h` and `Ast/src/PrettyPrinter.cpp`. The header declared `std::string prettyPrint(AstStatBlock& ast);` but the implementation was missing. The implementation had `std::string prettyPrint(AstStatBlock& block, const CstNodeMap& cstNodeMap)` but it was not declared in the header. Changes: - Added `std::string prettyPrint(AstStatBlock& block, const CstNodeMap& cstNodeMap);` to `PrettyPrinter.h`. - Implemented `std::string prettyPrint(AstStatBlock& block)` in `PrettyPrinter.cpp` (delegating to the 2-arg version). - Added a unit test to verify `prettyPrint(AstStatBlock&)` works correctly. --- Fixes #2206 --------- Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com>
Additionally, adds a new test, as well as the flag `LuauUdtfTypeIsSubtypeOf` https://rfcs.luau.org/method-type-issubtypeof.html luau-lang/rfcs#101 --------- Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com>
Wake up babe, another Luau release just dropped! ### Analysis - Introduce `ConstraintGraph`, an abstraction over the set of constraints, types, and type packs in use during type inference and their dependencies. - Various bug fixes to user defined type functions. ### Runtime - VM: Fix direct userdata access patching already deoptimized instructions - Compiler: Exploit more opportunities for constant table folding. - Compiler: Inline table function expressions. - Bytecode: Implement inlining of calls in bytecode. --- Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Ilya Rezvov <irezvov@roblox.com> Co-authored-by: James McNellis <jmcnellis@roblox.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Thomas Schollenberger <tschollenberger@roblox.com> Co-authored-by: Varun Saini <vsaini@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
#2133 introduced new embedded type method definitions for `issubtypeof` in a way that it implicitly exposes integers even when `LuauIntegerType2` isn't on. We should reflag this so that `LuauUdtfTypeIsSubtypeOf` and `LuauIntegerType2` are separate.
CFG dump printed type guards as `x-0 typeof == "string"` instead of `typeof(x-0) == "string" The rest of the dumper renders correctly Co-authored-by: dr_breen <mewheni777@gmail.com>
Hi everyone! The Luau team has been flibbertigibbeting and recombobulating this week to bring another release to you! Check out what's new: ### Analysis * Fixes an error where Luau script analysis would sometimes incorrectly infer that `Library.table.unpack` returns `...unknown` * Writing a recursive generic type alias with the wrong number of generics now reports one more specific error rather than two. * Fixed a crash that could happen when normalizing an exceptionally large negated type. * Improved performance in constraint solving when reducing large nested type functions. * Fixed a crash that could happen when combining `export` and `class`. ### Compiler & Runtime * Luau C API will now auto-reserve required stack slots to reduce API errors, eliminating the need for manual stack management with `lua_checkstack` * Add support for yieldable protected C calls for custom Luau libraries via `luaL_pcallyieldable` * NCG: Remove the use of shared execution callback data for register spills * Updates the garbage collector to visit cached tagged userdata metatables, preventing premature collection and making the lua_setuserdatametatable API less error-prone. * Fixed two compiler crashes related to `export`. ----------------- As always, thanks to all our contributors, and happy pride and FIFA world cup!!! 🏳️🌈 ⚽️ 🏆 Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Annie Tang <annietang@roblox.com> Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Thomas Schollenberger <tschollenberger@roblox.com> Co-authored-by: Varun Saini <vsaini@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Ilya Rezvov <irezvov@roblox.com>
…extension before erroring (#2415) Makes the CLI try to find the provided file name with a `.luau` or `.lua` file extension before throwing an `Error Opening: ` error Closes #2416
…er error (#2452) Fixes a new warning in `doctest.h` after GitHub actions updated the MSVC compiler from v17 to v18. A patch was added during the 725 release last week but this PR moves the `DOCTEST_CONFIG_USE_STD_HEADERS` define into CmakeLists and Makefile instead of at the top of `doctest.h`
Happy end of July! In accordance with Zeus's law, the Luau team is bringing forth another exciting release! 🌩️⚡️ ## General * Added the ability to parse config files from bytecode rather than source! * Fixups for `DenseHash2` * More optimizations for the `export` keyword * More internal refactoring and development to support cyclic module dependencies for exported modules ## Analysis * Zero-argument type functions no longer break when exported, resolving luau-lang/luau#2554 * Enable type function evaluation in fragment autocomplete, so: ```lua type function test(ty: type) return types.unionof(types.singleton('test'), types.singleton('test2')) end local a: test<number> = 'test' -- autocomplete now shows up when adding quotes or filling the word "test" in ``` ## Runtime * Add bytecode version for double-precision vector constants + options fix * Switch Luau C Closure debugname from `const char*` to `TString*` * Luau NCG: fixed an issue where linear code blocks generated unreachable code * Luau NCG: improved spill restore location hints which should reduce spill slot pressure * Luau NCG: improved unnecessary tag check removal optimization * Fixed luau-lang/luau#1893 --------------------------------- And, as always, thanks to all our contributors! Co-authored-by: Annie Tang <annietang@roblox.com> Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Ilya Rezvov <irezvov@roblox.com> Co-authored-by: Jason Rodrigues <jrodrigues@roblox.com> Co-authored-by: Phil Pizlo <fpizlo@roblox.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Thomas Schollenberger <tschollenberger@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Ariel Weiss <arielweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Ilya Rezvov <irezvov@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Involves removing some of our own bespoke implementations of things (like integers and yieldable __iter), as well as changing ares to better handle Luau versions changing type tags. classes and objects are not yet implemented in Ares, as they're still shifting around.