mirror of
https://github.com/luau-lang/luau.git
synced 2025-08-26 11:27:08 +01:00
# What's Changed? This week comes with many improvements to the new type solver and an important fix to the garbage collection to make it more robust in memory constrained scenarios. # Runtime - Garbage collection will no longer run out of memory itself, which could have happened when resizing arrays to a smaller size # New Type Solver - Type refinements on external types should now work and should no longer normalize the type into `never` - Improved error reporting when `string.format` is used with a dynamic format string - Updated type signature of `getmetatable` library function to use the corresponding type function and produce better type inference - Restored a type mismatch error when converting function types with different number of generic parameters, like `() -> ()` into `<T>() -> ()` - Types resulting from compound assignments have been simplified, reducing cyclic type introduction and inference failures - Fixed function generic types leaking into tables during bidirectional type inference (Fixes #1808 and #1821 ) - Stability and performance improvements (Fixes #1860 ) # 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: Sora Kanosue <skanosue@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>
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#include "Fixture.h"
|
|
|
|
#include "Luau/InferPolarity.h"
|
|
#include "Luau/Polarity.h"
|
|
#include "Luau/Type.h"
|
|
#include "Luau/TypeArena.h"
|
|
|
|
using namespace Luau;
|
|
|
|
LUAU_FASTFLAG(LuauEagerGeneralization3);
|
|
|
|
TEST_SUITE_BEGIN("InferPolarity");
|
|
|
|
TEST_CASE_FIXTURE(Fixture, "T where T = { m: <a>(a) -> T }")
|
|
{
|
|
ScopedFastFlag sff{FFlag::LuauEagerGeneralization3, true};
|
|
|
|
TypeArena arena;
|
|
ScopePtr globalScope = std::make_shared<Scope>(builtinTypes->anyTypePack);
|
|
|
|
TypeId tType = arena.addType(BlockedType{});
|
|
TypeId aType = arena.addType(GenericType{globalScope.get(), "a"});
|
|
|
|
TypeId mType = arena.addType(FunctionType{
|
|
TypeLevel{},
|
|
/* generics */ {aType},
|
|
/* genericPacks */ {},
|
|
/* argPack */ arena.addTypePack({aType}),
|
|
/* retPack */ arena.addTypePack({tType})
|
|
});
|
|
|
|
emplaceType<TableType>(
|
|
asMutable(tType),
|
|
TableType{
|
|
TableType::Props{{"m", Property::rw(mType)}},
|
|
/* indexer */ std::nullopt,
|
|
TypeLevel{},
|
|
globalScope.get(),
|
|
TableState::Sealed
|
|
}
|
|
);
|
|
|
|
inferGenericPolarities(NotNull{&arena}, NotNull{globalScope.get()}, tType);
|
|
|
|
const GenericType* aGeneric = get<GenericType>(aType);
|
|
REQUIRE(aGeneric);
|
|
CHECK(aGeneric->polarity == Polarity::Negative);
|
|
}
|
|
|
|
TEST_SUITE_END();
|