mirror of
https://github.com/luau-lang/luau.git
synced 2025-08-26 11:27:08 +01:00
# What's Changed? We've been hard at work fixing bugs and introducing new features! ## VM * Include constant-folding information in Luau cost model for inlining and loop unrolling * ~1% improvement in compile times ## New Type Solver * `Luau::shallowClone`'s last argument, whether to clone persistent (builtin) types, is now non-optional. * Refinements on properties of tables are now computed with a `read` table property. This resolves some issues around refining table properies and then trying to set them. Fixes #1344. Fixes #1651. ``` if foo.bar then -- Prior to this release, this would be `typeof(foo) & { bar: ~(false?) } -- Now, this is `typeof(foo) & { read bar: ~(false?) } end ``` * The type function `keyof` should respect the empty string as a property, as in: ``` -- equivalent to type Foo ="" type Foo = keyof<{ [""]: number }> ``` * Descend into literals to report subtyping errors for function calls: this both improves bidirectional inference and makes errors more specific. Before, the error reporting for a table with incorrect members passed to a function would cite the entire table, but now it only cites the members that are incorrectly typed. * Fixes a case where intersecting two tables without any common properties would create `never`, instead of a table with both of their properties. # Internal Contributors 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: 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>
47 lines
1.9 KiB
C++
47 lines
1.9 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#pragma once
|
|
|
|
#include <Luau/NotNull.h>
|
|
#include "Luau/TypeArena.h"
|
|
#include "Luau/Type.h"
|
|
#include "Luau/Scope.h"
|
|
|
|
#include <unordered_map>
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
// Only exposed so they can be unit tested.
|
|
using SeenTypes = std::unordered_map<TypeId, TypeId>;
|
|
using SeenTypePacks = std::unordered_map<TypePackId, TypePackId>;
|
|
|
|
struct CloneState
|
|
{
|
|
NotNull<BuiltinTypes> builtinTypes;
|
|
|
|
SeenTypes seenTypes;
|
|
SeenTypePacks seenTypePacks;
|
|
};
|
|
|
|
/** `shallowClone` will make a copy of only the _top level_ constructor of the type,
|
|
* while `clone` will make a deep copy of the entire type and its every component.
|
|
*
|
|
* Be mindful about which behavior you actually _want_.
|
|
*
|
|
* Persistent types are not cloned as an optimization.
|
|
* If a type is cloned in order to mutate it, 'clonePersistentTypes' has to be set
|
|
*/
|
|
TypePackId shallowClone(TypePackId tp, TypeArena& dest, CloneState& cloneState, bool clonePersistentTypes);
|
|
TypeId shallowClone(TypeId typeId, TypeArena& dest, CloneState& cloneState, bool clonePersistentTypes);
|
|
|
|
TypePackId clone(TypePackId tp, TypeArena& dest, CloneState& cloneState);
|
|
TypeId clone(TypeId tp, TypeArena& dest, CloneState& cloneState);
|
|
TypeFun clone(const TypeFun& typeFun, TypeArena& dest, CloneState& cloneState);
|
|
Binding clone(const Binding& binding, TypeArena& dest, CloneState& cloneState);
|
|
|
|
TypePackId cloneIncremental(TypePackId tp, TypeArena& dest, CloneState& cloneState, Scope* freshScopeForFreeTypes);
|
|
TypeId cloneIncremental(TypeId typeId, TypeArena& dest, CloneState& cloneState, Scope* freshScopeForFreeTypes);
|
|
TypeFun cloneIncremental(const TypeFun& typeFun, TypeArena& dest, CloneState& cloneState, Scope* freshScopeForFreeTypes);
|
|
Binding cloneIncremental(const Binding& binding, TypeArena& dest, CloneState& cloneState, Scope* freshScopeForFreeTypes);
|
|
|
|
} // namespace Luau
|