mirror of
https://github.com/luau-lang/luau.git
synced 2025-04-02 01:40:54 +01:00
As always, a weekly Luau update! This week we have further improvements to new type solver, fixing a few of the popular issues reported. The fragment autocomplete is even more stable and we believe it's ready for broader use. Aside from that we have a few general fixes/improvements: * Fixed data race when multi-threaded typechecking is used, appearing as a random crash at the end of typechecking * AST data is now available from `Luau::Module` ## New Type Solver * Fixed type refinements made by function calls which could attach `nil` as an option of a type before (Fixes #1528) * Improved bidirectional typechecking in tables (Fixes #1596) * Fixed normalization of negated types * `getmetatable()` on `any` type should no longer report an error ## Fragment Autocomplete * Fixed auto-complete suggestions being provided inside multiline comments * Fixed an assertion failure that could happen when old type solver was used * Fixed issues with missing suggestions when multiple statements are on the same line * Fixed memory safety issues ## Internal Contributors Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
48 lines
1.9 KiB
C++
48 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, 'ignorePersistent' has to be set
|
|
*/
|
|
|
|
TypePackId shallowClone(TypePackId tp, TypeArena& dest, CloneState& cloneState, bool ignorePersistent = false);
|
|
TypeId shallowClone(TypeId typeId, TypeArena& dest, CloneState& cloneState, bool ignorePersistent = false);
|
|
|
|
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
|