mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 21:10:37 +00:00
d518d14b92
### What's new * Fixed many of the false positive errors in indexing of table unions and table intersections * It is now possible to run custom checks over Luau AST during typechecking by setting `customModuleCheck` in `FrontendOptions` * Fixed codegen issue on arm, where number->vector cast could corrupt that number value for the next time it's read ### New Solver * `error` type now behaves as the bottom type during subtyping checks * Fixed the scope that is used in subtyping with generic types * Fixed `astOriginalCallTypes` table often used by LSP to match the old solver --- ### Internal Contributors Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
72 lines
1.8 KiB
C++
72 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
|
|
|
|
#include "Fixture.h"
|
|
|
|
#include "Luau/RecursionCounter.h"
|
|
|
|
#include "doctest.h"
|
|
|
|
using namespace Luau;
|
|
|
|
LUAU_FASTINT(LuauVisitRecursionLimit);
|
|
LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution)
|
|
|
|
TEST_SUITE_BEGIN("VisitType");
|
|
|
|
TEST_CASE_FIXTURE(Fixture, "throw_when_limit_is_exceeded")
|
|
{
|
|
if (FFlag::DebugLuauDeferredConstraintResolution)
|
|
{
|
|
CheckResult result = check(R"(
|
|
local t : {a: {b: {c: {d: {e: boolean}}}}}
|
|
)");
|
|
ScopedFastInt sfi{FInt::LuauVisitRecursionLimit, 3};
|
|
TypeId tType = requireType("t");
|
|
|
|
CHECK_THROWS_AS(toString(tType), RecursionLimitException);
|
|
}
|
|
else
|
|
{
|
|
ScopedFastInt sfi{FInt::LuauVisitRecursionLimit, 3};
|
|
|
|
CheckResult result = check(R"(
|
|
local t : {a: {b: {c: {d: {e: boolean}}}}}
|
|
)");
|
|
|
|
TypeId tType = requireType("t");
|
|
|
|
CHECK_THROWS_AS(toString(tType), RecursionLimitException);
|
|
}
|
|
}
|
|
|
|
TEST_CASE_FIXTURE(Fixture, "dont_throw_when_limit_is_high_enough")
|
|
{
|
|
ScopedFastInt sfi{FInt::LuauVisitRecursionLimit, 8};
|
|
|
|
CheckResult result = check(R"(
|
|
local t : {a: {b: {c: {d: {e: boolean}}}}}
|
|
)");
|
|
|
|
TypeId tType = requireType("t");
|
|
|
|
(void)toString(tType);
|
|
}
|
|
|
|
TEST_CASE_FIXTURE(Fixture, "some_free_types_do_not_have_bounds")
|
|
{
|
|
Type t{FreeType{TypeLevel{}}};
|
|
|
|
(void)toString(&t);
|
|
}
|
|
|
|
TEST_CASE_FIXTURE(Fixture, "some_free_types_have_bounds")
|
|
{
|
|
ScopedFastFlag sff{FFlag::DebugLuauDeferredConstraintResolution, true};
|
|
|
|
Scope scope{builtinTypes->anyTypePack};
|
|
Type t{FreeType{&scope, builtinTypes->neverType, builtinTypes->numberType}};
|
|
|
|
CHECK("('a <: number)" == toString(&t));
|
|
}
|
|
|
|
TEST_SUITE_END();
|