mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 22:35:43 +08:00
9c2146288d
# What's changed? * Support for new 'require by string' RFC with relative paths and aliases in now enabled in Luau REPL application ### New Type Solver * Fixed assertion failure on generic table keys (`[expr] = value`) * Fixed an issue with type substitution traversing into the substituted parts during type instantiation * Fixed crash in union simplification when that union contained uninhabited unions and other types inside * Union types in binary type families like `add<a | b, c>` are expanded into `add<a, c> | add<b, c>` to handle * Added handling for type family solving creating new type families * Fixed a bug with normalization operation caching types with unsolved parts * Tables with uninhabited properties are now simplified to `never` * Fixed failures found by fuzzer ### Native Code Generation * Added support for shared code generation between multiple Luau VM instances * Fixed issue in load-store propagation and new tagged LOAD_TVALUE instructions * Fixed issues with partial register dead store elimination causing failures in GC assists --- ### Internal Contributors Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: James McNellis <jmcnellis@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
83 lines
2.6 KiB
C++
83 lines
2.6 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/Substitution.h"
|
|
#include "Luau/TxnLog.h"
|
|
#include "Luau/TypeFwd.h"
|
|
#include "Luau/Unifiable.h"
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
struct TypeArena;
|
|
struct TypeCheckLimits;
|
|
|
|
struct Replacer : Substitution
|
|
{
|
|
DenseHashMap<TypeId, TypeId> replacements;
|
|
DenseHashMap<TypePackId, TypePackId> replacementPacks;
|
|
|
|
Replacer(NotNull<TypeArena> arena, DenseHashMap<TypeId, TypeId> replacements, DenseHashMap<TypePackId, TypePackId> replacementPacks)
|
|
: Substitution(TxnLog::empty(), arena)
|
|
, replacements(std::move(replacements))
|
|
, replacementPacks(std::move(replacementPacks))
|
|
{
|
|
}
|
|
|
|
bool isDirty(TypeId ty) override
|
|
{
|
|
return replacements.find(ty) != nullptr;
|
|
}
|
|
|
|
bool isDirty(TypePackId tp) override
|
|
{
|
|
return replacementPacks.find(tp) != nullptr;
|
|
}
|
|
|
|
TypeId clean(TypeId ty) override
|
|
{
|
|
TypeId res = replacements[ty];
|
|
LUAU_ASSERT(res);
|
|
dontTraverseInto(res);
|
|
return res;
|
|
}
|
|
|
|
TypePackId clean(TypePackId tp) override
|
|
{
|
|
TypePackId res = replacementPacks[tp];
|
|
LUAU_ASSERT(res);
|
|
dontTraverseInto(res);
|
|
return res;
|
|
}
|
|
};
|
|
|
|
// A substitution which replaces generic functions by monomorphic functions
|
|
struct Instantiation2 : Substitution
|
|
{
|
|
// Mapping from generic types to free types to be used in instantiation.
|
|
DenseHashMap<TypeId, TypeId> genericSubstitutions{nullptr};
|
|
// Mapping from generic type packs to `TypePack`s of free types to be used in instantiation.
|
|
DenseHashMap<TypePackId, TypePackId> genericPackSubstitutions{nullptr};
|
|
|
|
Instantiation2(TypeArena* arena, DenseHashMap<TypeId, TypeId> genericSubstitutions, DenseHashMap<TypePackId, TypePackId> genericPackSubstitutions)
|
|
: Substitution(TxnLog::empty(), arena)
|
|
, genericSubstitutions(std::move(genericSubstitutions))
|
|
, genericPackSubstitutions(std::move(genericPackSubstitutions))
|
|
{
|
|
}
|
|
|
|
bool ignoreChildren(TypeId ty) override;
|
|
bool isDirty(TypeId ty) override;
|
|
bool isDirty(TypePackId tp) override;
|
|
TypeId clean(TypeId ty) override;
|
|
TypePackId clean(TypePackId tp) override;
|
|
};
|
|
|
|
std::optional<TypeId> instantiate2(
|
|
TypeArena* arena, DenseHashMap<TypeId, TypeId> genericSubstitutions, DenseHashMap<TypePackId, TypePackId> genericPackSubstitutions, TypeId ty);
|
|
std::optional<TypePackId> instantiate2(TypeArena* arena, DenseHashMap<TypeId, TypeId> genericSubstitutions,
|
|
DenseHashMap<TypePackId, TypePackId> genericPackSubstitutions, TypePackId tp);
|
|
|
|
} // namespace Luau
|