mirror of
https://github.com/luau-lang/luau.git
synced 2025-04-21 04:03:47 +01:00
# General This week has been focused primarily on bugfixes, with a ton of usability improvements to the new solver, fragment autocomplete, and the concrete syntax tree project. ## Runtime - Fix an assertion caused by failing to allocate native code pages. - Expose a `lua_pushrequire` function, which performs the same initialization steps as `luaopen_require` but does not register require globally. This lets users create specialized, custom `requires`. # New Solver - Fix a bug in simplification of types caused by combinatorial explosion of intersection and union types. - Fix a memory leak in fragment autocomplete - Improve the isolation of modules in fragment autocomplete - Throw errors when users define a type function with the name `typeof` - Continue to narrow intersection types which might be `never`. - Major rework of generalization continues - we are blazing a new path with eager + non-reentrant generalization and actively working to make these more performant and less error prone. - Improve the ability of `and/or` type functions to reduce, even when their arguments are generic. - Report arity mismatches for undersaturated calls with unknown parameters # New Non-Strict - Extends the new non-strict mode to report unknown symbols in types # Old Solver - Fix a crash caused by excessive stack usage during typechecking # Misc - Improvements to Concrete Syntax Tree location tracking for string table props. --- Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Ariel Weiss <aaronweiss@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Sora Kanosue <skanosue@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>
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(LuauNonReentrantGeneralization2);
|
|
|
|
TEST_SUITE_BEGIN("InferPolarity");
|
|
|
|
TEST_CASE_FIXTURE(Fixture, "T where T = { m: <a>(a) -> T }")
|
|
{
|
|
ScopedFastFlag sff{FFlag::LuauNonReentrantGeneralization2, 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();
|