-
Notifications
You must be signed in to change notification settings - Fork 1
Merge upstream Luau 0.691 #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
## What's Changed? This week we have an update with an implementation for one of the RFCs we had approved before, an improvement of the new type solver and a small Lua 5.1 C API compatibility improvement. * `@deprecated` attribute can now have a custom suggestion for a replacement and a reason message as described in [deprecated attribute parameters RFC](https://rfcs.luau.org/syntax-attribute-functions-deprecated.html) For example: ```luau @[deprecated {reason = "foo suffers from performance issues", use = "bar"}] local function foo() ... end -- Function 'foo' is deprecated, use 'bar' instead. foo suffers from performance issues foo() ``` * `lua_cpcall` C API function has been restored both for compatibility with Lua 5.1 and as a safe way to enter protected call environment to work with Luau C API functions that may error Instead of ``` if (!lua_checkstack(L, 2)) return -1; lua_pushcfunction(L, test, nullptr); lua_pushlightuserdata(L, context); int status = lua_pcall(L, 1, 0, 0); ``` you can simply do ``` int status = lua_cpcall(L, test, context); ``` * In Luau CLI, required module return values can now have any type ## New Type Solver - Additional improvements on type refinements used with external types should fix some reported false positive errors where types refined to `never` - Fixed an issue in recursive refinement types in a form of `t1 where t1 = refine<t1, _>` getting 'stuck' - Fixed an issue in subtyping of generic functions, it is now possible to assign `<T>(T, (T) -> T) -> T` to `(number, <X>(X) -> X) -> number` - Fixed an ICE caused by recursive types (Fixes #1686) - Added additional iteration and recursion limits to stop the type solver before system resources are used up ## Internal Contributors Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Annie Tang <annietang@roblox.com> Co-authored-by: Ariel Weiss <aaronweiss@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>
This PR fixes the fuzzer always being built even when LUAU_BUILD_TESTS is off. This is done by moving the `include_subdirectory` for the fuzzer inside of the if block under LUAU_BUILD_TESTS.
# General Improvements
* Fix a crash that could occur when the `deprecated` attribute is used
in a syntactically incorrect way.
* Improve stack utilization in the parser. This should make it harder
for deeply nested constructs to exhaust the C stack.
* Fixed the `xpcall` continuation to handle errors handling the same way
as main execution path.
* The fuzzer now enables all Luau flags..
* The fuzzer will now add attributes and create table literal
expressions.
* The type of `rawget` is now `<K, V>(tab: {[K]: V}, k: K) -> V?` to
reflect the fact that it returns `nil` when the key is not present.
* Implement native codegen lowering for `vector.lerp`
# Autocomplete
* Autocomplete will also now suggest hot comments like `--!strict` and
`--!optimize`
* Incremental autocomplete had a bug where it wasn't selecting the
correct refinement of the autocomplete subject. This is now fixed.
# New Solver
* Fix an incorrect refinement that caused autocomplete to fail on
statements of the following form: `if #some_local.`
* Improve the error feedback when a type function is not passed required
arguments. (ie no `<>` afterward at all)
* Improvements to bidirectional table inference
## 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: Ilya Rezvov <irezvov@roblox.com>
Co-authored-by: Sora Kanosue <skanosue@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: Hunter Goldstein <hgoldstein@roblox.com>
Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com>
Co-authored-by: Alexander Youngblood <ayoungblood@roblox.com>
Co-authored-by: Menarul Alam <malam@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Ariel Weiss <aaronweiss@roblox.com>
# New Type Solver
* Improve the error message for an uninstantiated type alias, as in:
```luau
type Packed<T...> = (T...) -> T...
local a: Packed -- Now has a single, specific, error
```
* Improve refinements of extern types against table types, ensuring the
extern part is dropped less often, as in:
```luau
local function update(foo: Instance)
assert(foo.Name == "bubbles")
-- Previously might have been `{ read Name: "bubbles" }`,
-- will now be `Instance & { read Name: "bubbles" }`
return foo
end
```
* Resolve an internal complier exception when attempting to use `typeof`
inside the generic type default of an alias. Fixes #1462.
* No longer throw an internal compiler exception for exceptionally large
ASTs, though a `CodeTooComplex` error will still be raised.
* Broadly rework generic pack subtyping to allow code like the following
to type check without errors:
```luau
function f(foo: (number) -> number): () end
type T = <A...>(A...) -> number
local t: T
-- OK, as a function that takes some generic pack of arguments can receive a `number` as well.
f(t)
```
* Report an error when a type pack is provided to a generic alias that
can receive a type _and_ a type pack, as in:
```luau
type Y<T = string, U... = ...string> = { a: (T) -> U... }
-- Now errors as you must provide a type before the pack.
local a: Y<...number>
```
* Fix an instance of generics leaking when returning a function from
another function with explicitly defined generics. Fixes #1971.
* Cache `HasPropConstraint`s such that for every pair of subject type
and desired property, we only emit a single constraint and blocked type;
this incidentally fixes some bugs around inferring the types of
properties on `self`.
* Table types associated with table literals are now tracked specially
to make type checking more permissive, such as in:
```luau
type Foo = { name: string?, flag: boolean? }
local arr: {Foo} = {}
local function foo(arg: {name: string}?)
local name = if arg and arg.name then arg.name else nil
-- Previously would error as bidirectional inference would not
-- kick in as often.
table.insert(arr, {
name = name or "",
flag = name ~= nil and name ~= "",
})
end
```
# Native Codegen
* Lowering to arm64 for some local heavy functions will now succeed
whereas prior they failed due to running out of registers for live
values.
---
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: Sora Kanosue <skanosue@roblox.com>
Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
…e REPL's require implementation (#1967) This PR changes the Luau CLI to allow string values to be returned from required files and to error whenever a file returns no values or more than one value.
# New Type Solver * Fixed luau-lang/luau#1983 by adding additional context to permit some expressions otherwise not allowed * We now skip issuing CheckedFunctionWarnings on use of unreduced type functions * Fix gcc compile error * Handle expressions `a == b` and `a ~= b` more efficiently * Subtyping now correctly handles generics over unions and intersections in cases such as ``` local function a<T>(arr: { T }) end a({ 'one', 'two' }) ``` * Rearrange unification cases to avoid free type generalization to never * Improve generic bounds mismatch error message * Fix Ancestry bug in visitor for incomplete repeat blocks such as ``` local t = {} function t:Foo() end repeat t:| ``` * Support autocomplete for attributes # Native Codegen * Unwind info has support on Android * Introduced a separate ctypeof function which does not constant-fold for vector arguments. * We now perform string concatenation at compile time if possible (there is a known issue with the optimization that we will address next week) * Make vector.lerp and math.lerp more efficient with FMA * Record STORE_SPLIT_TVALUE as a potential restore operation to reduce number of spills to stack * When native execution is disabled, we now mark the call frame as not executing natively, making resumption safer --- 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: Varun Saini <vsaini@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@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: Alexander Youngblood <ayoungblood@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: Vighnesh <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Ariel Weiss <aaronweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com>
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.
No description provided.