Noticed while using luau-ast that function attributes aren't included in
the output. This PR corrects that.
---------
Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com>
Closes#1460.
This renames the `type` field of `AstStatTypeAlias` to `value` during
the JSON encoding process.
I've chosen to just rename the field in the JSON encoder rather than
rename the actual field since it's a lot further reaching. Another
option would have been to rename what the actual type of an AST node is
written to be something like `tokenType` instead of `type`, but that's a
bigger diff and technically breaking (as opposed to this one which
isn't!)
# General Updates
* Fix some cases where documentation symbols would not be available when
mouseovering at certain positions in the code
* Scaffolding to help embedders have more control over how `typeof(x)`
refines types
* Refinements to require-by-string semantics. See
https://github.com/luau-lang/rfcs/pull/56 for details.
* Fix for https://github.com/luau-lang/luau/issues/1405
# New Solver
* Fix many crashes (thanks you for your bug reports!)
* Type functions can now call each other
* Type functions all evaluate in a single VM. This should improve
typechecking performance and reduce memory use.
* `export type function` is now forbidden and fails with a clear error
message
* Type functions that access locals in the surrounding environment are
now properly a parse error
* You can now use `:setindexer(types.never, types.never)` to delete an
indexer from a table type.
# Internal Contributors
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com>
Co-authored-by: Varun Saini <vsaini@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
In this update, we continue to improve the overall stability of the new
type solver. We're also shipping some early bits of two new features,
one of the language and one of the analysis API: user-defined type
functions and an incremental typechecking API.
If you use the new solver and want to use all new fixes included in this
release, you have to reference an additional Luau flag:
```c++
LUAU_DYNAMIC_FASTINT(LuauTypeSolverRelease)
```
And set its value to `645`:
```c++
DFInt::LuauTypeSolverRelease.value = 645; // Or a higher value for future updates
```
## New Solver
* Fix a crash where scopes are incorrectly accessed cross-module after
they've been deallocated by appropriately zeroing out associated scope
pointers for free types, generic types, table types, etc.
* Fix a crash where we were incorrectly caching results for bound types
in generalization.
* Eliminated some unnecessary intermediate allocations in the constraint
solver and type function infrastructure.
* Built some initial groundwork for an incremental typecheck API for use
by language servers.
* Built an initial technical preview for [user-defined type
functions](https://rfcs.luau-lang.org/user-defined-type-functions.html),
more work still to come (including calling type functions from other
type functions), but adventurous folks wanting to experiment with it can
try it out by enabling `FFlag::LuauUserDefinedTypeFunctionsSyntax` and
`FFlag::LuauUserDefinedTypeFunction` in their local environment. Special
thanks to @joonyoo181 who built up all the initial infrastructure for
this during his internship!
## Miscellaneous changes
* Fix a compilation error on Ubuntu (fixes#1437)
---
Internal Contributors:
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com>
Co-authored-by: Jeremy Yoo <jyoo@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
---------
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Junseo Yoo <jyoo@roblox.com>
In this update we improve overall stability of the new type solver and
address some type inference issues with it.
If you use the new solver and want to use all new fixes included in this
release, you have to reference an additional Luau flag:
```c++
LUAU_DYNAMIC_FASTINT(LuauTypeSolverRelease)
```
And set its value to `644`:
```c++
DFInt::LuauTypeSolverRelease.value = 644; // Or a higher value for future updates
```
## New Solver
* Fixed a debug assertion failure in autocomplete (Fixes#1391)
* Fixed type function distribution issue which transformed `len<>` and
`unm<>` into `not<>` (Fixes#1416)
* Placed a limit on the possible normalized table intersection size as a
temporary measure to avoid hangs and out-of-memory issues for complex
type refinements
* Internal recursion limits are now respected in the subtyping
operations and in autocomplete, to avoid stack overflow crashes
* Fixed false positive errors on assignments to tables whose indexers
are unions of strings
* Fixed memory corruption crashes in subtyping of generic types
containing other generic types in their bounds
---
Internal Contributors:
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Github has deprecated `v1` and `v2` of `actions/upload-artifact` which
causes occassional CI failures and will affect our ability to make new
releases in the future. This PR updates the version used in
`release.yml`.
Fix for https://github.com/luau-lang/luau/issues/1406
While it is good to let ``index`` wait for the pending-expansion. To
re-produce the issue you need more than just this code:
https://i.imgur.com/b3OmUGF.png
It needs this, else it won't crash.
```lua
local function ProblemCauser(key: Keys, value)
PlayerData[key] = value
end
```
But regarding "pending things", I'd recommend **generalized functions**
for sanity checks like these, since there will be more cases of similar
issues I believe. But I am 100% sure that eventually this issue here can
maybe be prevented if looking at the Constraints. _(And optimization)_
Not sure if ``index`` needs the table fully completed, or if it is
preferred that the info is available based on **how much info is
available at the current position in the code**.
But if this gets done, I hope that they'll be connected to the Solver
Logger, because I actually refined mine with colors and more info _(yet
need to finish that)_ to understand the Luau Source Code more and to
debug issues.
---------
Co-authored-by: aaron <aweiss@hey.com>
Fixes https://github.com/luau-lang/luau/issues/1387
Was suggested by @alexmccord
I changed ``singletons[0]`` to ``singletons.front()``, unsure if that
makes a huge difference, and then I added the rest of the things needed
for the return type.
Maybe it's also the ideal location since doing it before looping through
``keys`` won't add the string into the type arena.
I put comments next to it based on how I thought it would make sense.
``LUAU_ASSERT`` seems to trigger when there's only one entry being put
inside a UnionType. It's as if it was put there for quality.
Allow edits by maintainers is enabled.
I tested this with a quick Unit Test something like
```lua
local test: keyof<typeof({a="test"})>
```
## New Solver
* The type functions `keyof` and `index` now also walk the inheritance
chain when they are used on class types like Roblox instances.
---------
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
### What's new
* Light update this week, mostly fast flag cleanups.
### New Solver
* Rename flag to enable new solver from
`DebugLuauDeferredConstraintResolution` to `LuauSolverV2`
* Added support for magic functions for the new type checker (as opposed
to the type inference component)
* Improved handling of `string.format` with magic function improvements
* Cleaning up some of the reported errors by the new type checker
* Minor refactoring of `TypeChecker2.cpp` that happens to make the diff
very hard to read.
---
### Internal Contributors
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
---------
Co-authored-by: Alexander McCord <amccord@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: David Cope <dcope@roblox.com>
Co-authored-by: Lily Brown <lbrown@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Junseo Yoo <jyoo@roblox.com>
### What's new
* Fixed many of the false positive errors in indexing of table unions
and table intersections
* It is now possible to run custom checks over Luau AST during
typechecking by setting `customModuleCheck` in `FrontendOptions`
* Fixed codegen issue on arm, where number->vector cast could corrupt
that number value for the next time it's read
### New Solver
* `error` type now behaves as the bottom type during subtyping checks
* Fixed the scope that is used in subtyping with generic types
* Fixed `astOriginalCallTypes` table often used by LSP to match the old
solver
---
### Internal Contributors
Co-authored-by: Aaron Weiss <aaronweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>