mirror of
https://github.com/luau-lang/luau.git
synced 2025-08-26 11:27:08 +01:00
4 commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
|
92cce5776c
|
Sync to upstream/release/674 (#1832)
# General * Expose an optional `get_alias` API as an alternative to `get_config` in Luau.Require and Luau.RequireNavigator. * Improve the Luau CLI's virtual filesystem implementation to fix bugs related to `init.luau`. Fixes https://github.com/luau-lang/luau/issues/1816 # New Type Solver * Avoid double reporting errors when erroneous arguments are provided to type functions. * Fix some instances of unresovable cyclic type functions in loops by only considering the first loop cycles. This results in some type inference inaccuracies when the type of a variable in loop through multiple iterations. Fixes https://github.com/luau-lang/luau/issues/1413. * Better generalize free types that have meaningful lower and upper bounds, especially for table indexers. * Report more specific errors when assigning or returning table literal types, instead of citing the *entire* table type. * Inference for functions with generic type packs is greatly improved. * Fix some internal compiler exceptions when using type-stating functions like `table.freeze` in `if _ then _ else _` expressions and short circuiting binary operations. * More consistently simplify unions of primitive types, especially in array-like and dictionary-like tables. * Fix a crash when type checking an erroneous type alias containing `typeof` with a type assertion expression, as in: ``` type MyTable = {} -- This will error at type checking time as it's a duplicate type MyTable = typeof(setmetatable(SomeTable :: {}, SomeMetaTable)); ``` * Fix a crash when inferring the type of an index expression where the indexee is invalid (e.g. `nil`). # Runtime * Avoid throwing an exception from `luau_load` if we run out of memory. * Type functions are no longer compiled and included in bytecode. Fixes #1817. * Fix some instances of Luau C API functions reading invalid debug information (generally when the first or last instruction of a block was being inspected). Fixes #1369. * Avoid potential signed integer overflow when doing bounds checks on tables. * Support 16 byte aligned userdata objects when system allocation alignment is also 16 bytes. * Fix memory leaks in `Luau.Require` when using VM build with no exceptions. Fixes #1827. --------- Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Ariel Weiss <aaronweiss@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: Talha Pathan <tpathan@roblox.com> Co-authored-by: Varun Saini <vsaini@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> |
||
|
72f6c8b679
|
Sync to upstream/release/672 (#1800)
# What's Changed? Hi there, folks! It's been another busy week in the type mines, trying to bring you all the very best type inference system we can. We've got a bunch of updates to large pain points across the new type solver, and our next big update (currently under a debug flag) improving type generalization is finally nearing completion (and should hopefully eliminate quite a lot of "type solver failed to complete" errors). We've also continued polishing both the CST Parser and the `Luau.Require` library we introduced a few releases ago based on user feedback and bug reports, and we're really happy with how they're turning out. # Parser - Fixes a bug in the CST tooling where the spacing on return type annotations for functions was not being printed correctly. - Resolves some issues with the JSON encoding of `AstGenericType` and `AstGenericTypePack` # Runtime - Implements support for yielding requires in `Luau.Require` library. - Improves the error messages for require-by-string to include the chunk name that was problematic where possible and the overall require path that failed to be required. - Fixes a bug that prevented the use of `require` within C functions and `pcall`. - Adds an API to support selectively removing chunks from the require cache in `Luau.Require` - Adds an API to support clearing the entire require cache in `Luau.Require` # New Type Solver - Fixes a crash in the new non-strict mode when visiting function return types in incomplete ASTs (e.g. during editing). - Improves type simplification to support intersections of tables with extern types, resolving _one_ of the causes of frequent refinements unexpectedly leading to `never`. - Improves type inference to better understand diverging branches in functions, reducing false negatives where the type system fails to learn that a binding must now always be initialized. - Fixes a typo in the type definitions for user-defined function types where the `intersection` tag was misspelled. - Improves the overall accuracy of free type tracking during constraint solving, leading to better inference results overall. - Implements `types.optional` as a new library function for user-defined type functions to make it easier to union a type with `nil`. - Resolves a number of bugs caused by local type inference expanding the domain of upvalues # Internal Contributors Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Ariel Weiss <aaronweiss@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Talha Pathan <tpathan@roblox.com> Co-authored-by: Varun Saini <vsaini@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@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: Andy Friesen <afriesen@roblox.com> |
||
|
c51743268b
|
Sync to upstream/release/671 (#1787)
# General * Internally rename `ClassType` to `ExternType`. In definition files, the syntax to define these types has changed to `declare extern type Foo with prop: type end` * Add `luarequire_registermodule` to Luau.Require * Support yieldable Luau C functions calling other functions * Store return types as `AstTypePack*` on Ast nodes ## New Solver * Improve the logic that determines constraint dispatch ordering * Fix a crash in the type solver that arose when using multi-return functions with `string.format` * Fix https://github.com/luau-lang/luau/issues/1736 * Initial steps toward rethinking function generalization: * Instead of generalizing every type in a function all at once, we will instead generalize individual type variables once their bounds have been fully resolved. This will make it possible to properly interleave type function reduction and generalization. * Magic functions are no longer considered magical in cases where they are not explicitly called by the code. * The most prominent example of this is in `for..in` loops where the function call is part of the desugaring process. * Almost all magic functions work by directly inspecting the AST, so they can't work without an AST fragment anyway. * Further, none of the magic functions we have are usefully used in this way. Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Ariel Weiss <aaronweiss@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Sora Kanosue <skanosue@roblox.com> Co-authored-by: Talha Pathan <tpathan@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> |
||
|
a8d14596e7
|
Sync to upstream/release/669 (#1770)
We have lots of new changes for you! # What's Changed ## General - We updated Luau's license year to 2025! - We fixed a bug where large amounts of errors were being printed when deep intersections of unions error. ## Require-by-String This release introduces the `Luau.Require` library, which exposes the runtime semantics of require-by-string, including support for the new `@self` alias described in [this RFC](https://github.com/luau-lang/rfcs/pull/109). The library operates on a virtualized filesystem, allowing consumers to specify navigation rules without assuming a filesystem context. Documentation in `Require.h` explains how to enable the library, and the `setupState` function in Repl.cpp demonstrates how we've integrated it into the luau CLI tool. Note that the interface in `Require.h` is written in C, which enables any application written in a language with a C foreign-function interface to link against this library and enable require-by-string. This makes it straightforward for any application embedding Luau to support require-by-string, provided that it defines or operates within an environment resembling a virtual filesystem. The core navigation semantics of require-by-string have additionally been pulled into the `Luau.RequireNavigator` library. While `Luau.Require` internally depends on `Luau.RequireNavigator`, the latter does not depend on the Luau VM. This library provides an interface for inspecting require-by-string's navigation behavior and therefore serves as a useful dependency for static tooling. Documentation for `Luau.RequireNavigator` is available in `RequireNavigator.h`. ## Autocomplete - We fixed a memory leak in fragment autocomplete! ## New Solver And Old Solver - We've found a infinite iteration error over a type pack. We added a way to detect this error and throw an `InternalCompileError` instead. - We fix `table.freeze` not accounting for the first argument not getting type stated. We fall back to regular inference instead. - We fix a crash in the old solver with `length_error`. - We fix a crash in the new solver stemming from generalization reentrancy. Now we correctly generalize interior free types that do not appear in a function signature. - We fix a nil refinement. (Fixes https://github.com/luau-lang/luau/issues/1687 and https://github.com/luau-lang/luau/issues/1451) ### Internal Contributors Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Talha Pathan <tpathan@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> Full Changelog: https://github.com/luau-lang/luau/compare/0.668...0.669 --------- 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> |