mirror of
https://github.com/luau-lang/luau.git
synced 2025-03-04 03:01:41 +00:00

# General - Additional logging enabled for fragment autocomplete. ## Roundtrippable AST - Add a new `AstNode`, `AstGenericType` - Retain source information for `AstExprTypeAssertion` ## New Type Solver - New non-strict mode will report unknown symbol errors, e.g ``` foo = 5 local wrong1 = foob <- issue warning ``` - Fixed a bug where new non-strict mode failed to visit large parts of the program. - We now infer the types of unnanotated local variables in statements with multiple assignments, e.g. `local x: "a", y, z = "a", f()` - Fixed bugs in constraint dispatch ordering. - Fixed a bug that caused an infinite loop between `Subtyping`, `OverloadResolution`, and `Type Function Reduction`, by preventing calls to `Type Function Reduction` being re-entrant. - Fixed a crash in bidirectional type inference caused by asserting read and write properties on a type that was readonly. ## Runtime - Fix a stack overflow caused by `luaL_checkstack` consuming stack space even if the function fails to reserve memory. - Using '%c' with a 0 value in Luau string.format will append a '\0'. Resolves https://github.com/luau-lang/luau/issues/1650 ## Miscellaneous - Miscellaneous small bugfixes for the new solver. **Full Changelog**: https://github.com/luau-lang/luau/compare/0.660...0.661 ---- 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: 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>
75 lines
1.8 KiB
C++
75 lines
1.8 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/DenseHash.h"
|
|
#include "Luau/Error.h"
|
|
#include "Luau/TypeFwd.h"
|
|
|
|
#include <utility>
|
|
|
|
namespace Luau
|
|
{
|
|
struct InternalErrorReporter;
|
|
|
|
struct TypeIdPairHash
|
|
{
|
|
size_t hashOne(Luau::TypeId key) const
|
|
{
|
|
return (uintptr_t(key) >> 4) ^ (uintptr_t(key) >> 9);
|
|
}
|
|
|
|
size_t operator()(const std::pair<Luau::TypeId, Luau::TypeId>& x) const
|
|
{
|
|
return hashOne(x.first) ^ (hashOne(x.second) << 1);
|
|
}
|
|
};
|
|
|
|
struct UnifierCounters
|
|
{
|
|
int recursionCount = 0;
|
|
int recursionLimit = 0;
|
|
int iterationCount = 0;
|
|
int iterationLimit = 0;
|
|
};
|
|
|
|
struct UnifierSharedState
|
|
{
|
|
UnifierSharedState(InternalErrorReporter* iceHandler)
|
|
: iceHandler(iceHandler)
|
|
{
|
|
}
|
|
|
|
InternalErrorReporter* iceHandler;
|
|
|
|
DenseHashMap<TypeId, bool> skipCacheForType{nullptr};
|
|
DenseHashSet<std::pair<TypeId, TypeId>, TypeIdPairHash> cachedUnify{{nullptr, nullptr}};
|
|
DenseHashMap<std::pair<TypeId, TypeId>, TypeErrorData, TypeIdPairHash> cachedUnifyError{{nullptr, nullptr}};
|
|
|
|
DenseHashSet<TypeId> tempSeenTy{nullptr};
|
|
DenseHashSet<TypePackId> tempSeenTp{nullptr};
|
|
|
|
UnifierCounters counters;
|
|
|
|
bool reentrantTypeReduction = false;
|
|
|
|
};
|
|
|
|
struct TypeReductionRentrancyGuard final
|
|
{
|
|
explicit TypeReductionRentrancyGuard(NotNull<UnifierSharedState> sharedState)
|
|
: sharedState{sharedState}
|
|
{
|
|
sharedState->reentrantTypeReduction = true;
|
|
}
|
|
~TypeReductionRentrancyGuard()
|
|
{
|
|
sharedState->reentrantTypeReduction = false;
|
|
}
|
|
TypeReductionRentrancyGuard(const TypeReductionRentrancyGuard&) = delete;
|
|
TypeReductionRentrancyGuard(TypeReductionRentrancyGuard&&) = delete;
|
|
|
|
private:
|
|
NotNull<UnifierSharedState> sharedState;
|
|
};
|
|
|
|
} // namespace Luau
|