2021-10-29 16:25:12 -04:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
2023-02-24 16:49:38 -05:00
|
|
|
#include "Luau/Common.h"
|
2021-11-04 22:34:35 -04:00
|
|
|
#include "Luau/Scope.h"
|
2023-02-24 16:49:38 -05:00
|
|
|
#include "Luau/Symbol.h"
|
2021-10-29 16:25:12 -04:00
|
|
|
#include "Luau/TypeInfer.h"
|
2023-01-04 15:53:17 -05:00
|
|
|
#include "Luau/Type.h"
|
2021-10-29 16:25:12 -04:00
|
|
|
|
|
|
|
#include "Fixture.h"
|
|
|
|
|
|
|
|
#include "doctest.h"
|
|
|
|
|
|
|
|
using namespace Luau;
|
|
|
|
|
2023-02-24 16:49:38 -05:00
|
|
|
LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution)
|
|
|
|
|
2021-10-29 16:25:12 -04:00
|
|
|
struct TryUnifyFixture : Fixture
|
|
|
|
{
|
|
|
|
TypeArena arena;
|
|
|
|
ScopePtr globalScope{new Scope{arena.addTypePack({TypeId{}})}};
|
|
|
|
InternalErrorReporter iceHandler;
|
2021-11-05 11:47:21 -04:00
|
|
|
UnifierSharedState unifierState{&iceHandler};
|
2023-01-04 15:53:17 -05:00
|
|
|
Normalizer normalizer{&arena, builtinTypes, NotNull{&unifierState}};
|
2022-10-06 20:23:29 -04:00
|
|
|
Unifier state{NotNull{&normalizer}, Mode::Strict, NotNull{globalScope.get()}, Location{}, Variance::Covariant};
|
2021-10-29 16:25:12 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
TEST_SUITE_BEGIN("TryUnifyTests");
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "primitives_unify")
|
|
|
|
{
|
2023-01-04 15:53:17 -05:00
|
|
|
Type numberOne{TypeVariant{PrimitiveType{PrimitiveType::Number}}};
|
|
|
|
Type numberTwo = numberOne;
|
2021-10-29 16:25:12 -04:00
|
|
|
|
2022-01-06 20:46:53 -05:00
|
|
|
state.tryUnify(&numberTwo, &numberOne);
|
2021-10-29 16:25:12 -04:00
|
|
|
|
|
|
|
CHECK(state.errors.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "compatible_functions_are_unified")
|
|
|
|
{
|
2023-01-04 15:53:17 -05:00
|
|
|
Type functionOne{
|
|
|
|
TypeVariant{FunctionType(arena.addTypePack({arena.freshType(globalScope->level)}), arena.addTypePack({typeChecker.numberType}))}};
|
2021-10-29 16:25:12 -04:00
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
Type functionTwo{TypeVariant{
|
|
|
|
FunctionType(arena.addTypePack({arena.freshType(globalScope->level)}), arena.addTypePack({arena.freshType(globalScope->level)}))}};
|
2021-10-29 16:25:12 -04:00
|
|
|
|
2022-01-06 20:46:53 -05:00
|
|
|
state.tryUnify(&functionTwo, &functionOne);
|
2021-10-29 16:25:12 -04:00
|
|
|
CHECK(state.errors.empty());
|
|
|
|
|
2022-03-11 11:55:02 -05:00
|
|
|
state.log.commit();
|
2022-01-06 20:46:53 -05:00
|
|
|
|
2021-10-29 16:25:12 -04:00
|
|
|
CHECK_EQ(functionOne, functionTwo);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "incompatible_functions_are_preserved")
|
|
|
|
{
|
|
|
|
TypePackVar argPackOne{TypePack{{arena.freshType(globalScope->level)}, std::nullopt}};
|
2023-01-04 15:53:17 -05:00
|
|
|
Type functionOne{
|
|
|
|
TypeVariant{FunctionType(arena.addTypePack({arena.freshType(globalScope->level)}), arena.addTypePack({typeChecker.numberType}))}};
|
2021-10-29 16:25:12 -04:00
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
Type functionOneSaved = functionOne;
|
2021-10-29 16:25:12 -04:00
|
|
|
|
|
|
|
TypePackVar argPackTwo{TypePack{{arena.freshType(globalScope->level)}, std::nullopt}};
|
2023-01-04 15:53:17 -05:00
|
|
|
Type functionTwo{
|
|
|
|
TypeVariant{FunctionType(arena.addTypePack({arena.freshType(globalScope->level)}), arena.addTypePack({typeChecker.stringType}))}};
|
2021-10-29 16:25:12 -04:00
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
Type functionTwoSaved = functionTwo;
|
2021-10-29 16:25:12 -04:00
|
|
|
|
2022-01-06 20:46:53 -05:00
|
|
|
state.tryUnify(&functionTwo, &functionOne);
|
2021-10-29 16:25:12 -04:00
|
|
|
CHECK(!state.errors.empty());
|
|
|
|
|
|
|
|
CHECK_EQ(functionOne, functionOneSaved);
|
|
|
|
CHECK_EQ(functionTwo, functionTwoSaved);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "tables_can_be_unified")
|
|
|
|
{
|
2023-01-04 15:53:17 -05:00
|
|
|
Type tableOne{TypeVariant{
|
|
|
|
TableType{{{"foo", {arena.freshType(globalScope->level)}}}, std::nullopt, globalScope->level, TableState::Unsealed},
|
2021-10-29 16:25:12 -04:00
|
|
|
}};
|
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
Type tableTwo{TypeVariant{
|
|
|
|
TableType{{{"foo", {arena.freshType(globalScope->level)}}}, std::nullopt, globalScope->level, TableState::Unsealed},
|
2021-10-29 16:25:12 -04:00
|
|
|
}};
|
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
CHECK_NE(*getMutable<TableType>(&tableOne)->props["foo"].type, *getMutable<TableType>(&tableTwo)->props["foo"].type);
|
2021-10-29 16:25:12 -04:00
|
|
|
|
2022-01-06 20:46:53 -05:00
|
|
|
state.tryUnify(&tableTwo, &tableOne);
|
2021-10-29 16:25:12 -04:00
|
|
|
|
|
|
|
CHECK(state.errors.empty());
|
|
|
|
|
2022-03-11 11:55:02 -05:00
|
|
|
state.log.commit();
|
2022-01-06 20:46:53 -05:00
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
CHECK_EQ(*getMutable<TableType>(&tableOne)->props["foo"].type, *getMutable<TableType>(&tableTwo)->props["foo"].type);
|
2021-10-29 16:25:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "incompatible_tables_are_preserved")
|
|
|
|
{
|
2023-01-04 15:53:17 -05:00
|
|
|
Type tableOne{TypeVariant{
|
|
|
|
TableType{{{"foo", {arena.freshType(globalScope->level)}}, {"bar", {typeChecker.numberType}}}, std::nullopt, globalScope->level,
|
2021-10-29 16:25:12 -04:00
|
|
|
TableState::Unsealed},
|
|
|
|
}};
|
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
Type tableTwo{TypeVariant{
|
|
|
|
TableType{{{"foo", {arena.freshType(globalScope->level)}}, {"bar", {typeChecker.stringType}}}, std::nullopt, globalScope->level,
|
2021-10-29 16:25:12 -04:00
|
|
|
TableState::Unsealed},
|
|
|
|
}};
|
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
CHECK_NE(*getMutable<TableType>(&tableOne)->props["foo"].type, *getMutable<TableType>(&tableTwo)->props["foo"].type);
|
2021-10-29 16:25:12 -04:00
|
|
|
|
2022-01-06 20:46:53 -05:00
|
|
|
state.tryUnify(&tableTwo, &tableOne);
|
2021-10-29 16:25:12 -04:00
|
|
|
|
|
|
|
CHECK_EQ(1, state.errors.size());
|
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
CHECK_NE(*getMutable<TableType>(&tableOne)->props["foo"].type, *getMutable<TableType>(&tableTwo)->props["foo"].type);
|
2021-10-29 16:25:12 -04:00
|
|
|
}
|
|
|
|
|
2022-12-02 13:09:59 -05:00
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "uninhabited_intersection_sub_never")
|
|
|
|
{
|
|
|
|
CheckResult result = check(R"(
|
|
|
|
function f(arg : string & number) : never
|
|
|
|
return arg
|
|
|
|
end
|
|
|
|
)");
|
|
|
|
LUAU_REQUIRE_NO_ERRORS(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "uninhabited_intersection_sub_anything")
|
|
|
|
{
|
|
|
|
CheckResult result = check(R"(
|
|
|
|
function f(arg : string & number) : boolean
|
|
|
|
return arg
|
|
|
|
end
|
|
|
|
)");
|
|
|
|
LUAU_REQUIRE_NO_ERRORS(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "uninhabited_table_sub_never")
|
|
|
|
{
|
|
|
|
ScopedFastFlag sffs[]{
|
2022-12-09 14:57:01 -05:00
|
|
|
{"LuauUninhabitedSubAnything2", true},
|
2022-12-02 13:09:59 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
CheckResult result = check(R"(
|
|
|
|
function f(arg : { prop : string & number }) : never
|
|
|
|
return arg
|
|
|
|
end
|
|
|
|
)");
|
|
|
|
LUAU_REQUIRE_NO_ERRORS(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "uninhabited_table_sub_anything")
|
|
|
|
{
|
|
|
|
ScopedFastFlag sffs[]{
|
2022-12-09 14:57:01 -05:00
|
|
|
{"LuauUninhabitedSubAnything2", true},
|
2022-12-02 13:09:59 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
CheckResult result = check(R"(
|
|
|
|
function f(arg : { prop : string & number }) : boolean
|
|
|
|
return arg
|
|
|
|
end
|
|
|
|
)");
|
|
|
|
LUAU_REQUIRE_NO_ERRORS(result);
|
|
|
|
}
|
|
|
|
|
2021-10-29 16:25:12 -04:00
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "members_of_failed_typepack_unification_are_unified_with_errorType")
|
|
|
|
{
|
|
|
|
CheckResult result = check(R"(
|
|
|
|
function f(arg: number) end
|
|
|
|
local a
|
|
|
|
local b
|
|
|
|
f(a, b)
|
|
|
|
)");
|
|
|
|
|
|
|
|
LUAU_REQUIRE_ERROR_COUNT(1, result);
|
|
|
|
|
2021-11-19 11:10:07 -05:00
|
|
|
CHECK_EQ("a", toString(requireType("a")));
|
2022-11-04 13:33:22 -04:00
|
|
|
CHECK_EQ("*error-type*", toString(requireType("b")));
|
2021-11-19 11:10:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "result_of_failed_typepack_unification_is_constrained")
|
|
|
|
{
|
|
|
|
CheckResult result = check(R"(
|
|
|
|
function f(arg: number) return arg end
|
|
|
|
local a
|
|
|
|
local b
|
|
|
|
local c = f(a, b)
|
|
|
|
)");
|
|
|
|
|
|
|
|
LUAU_REQUIRE_ERROR_COUNT(1, result);
|
2021-10-29 16:25:12 -04:00
|
|
|
|
2021-11-19 11:10:07 -05:00
|
|
|
CHECK_EQ("a", toString(requireType("a")));
|
2022-11-04 13:33:22 -04:00
|
|
|
CHECK_EQ("*error-type*", toString(requireType("b")));
|
2021-11-19 11:10:07 -05:00
|
|
|
CHECK_EQ("number", toString(requireType("c")));
|
2021-10-29 16:25:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "typepack_unification_should_trim_free_tails")
|
|
|
|
{
|
|
|
|
CheckResult result = check(R"(
|
|
|
|
--!strict
|
|
|
|
local function f(v: number)
|
|
|
|
if v % 2 == 0 then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return function()
|
|
|
|
return (f(1))
|
|
|
|
end
|
|
|
|
)");
|
|
|
|
|
|
|
|
LUAU_REQUIRE_ERROR_COUNT(1, result);
|
2022-03-04 11:36:33 -05:00
|
|
|
CHECK_EQ("(number) -> boolean", toString(requireType("f")));
|
2021-10-29 16:25:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "variadic_type_pack_unification")
|
|
|
|
{
|
|
|
|
TypePackVar testPack{TypePack{{typeChecker.numberType, typeChecker.stringType}, std::nullopt}};
|
|
|
|
TypePackVar variadicPack{VariadicTypePack{typeChecker.numberType}};
|
|
|
|
|
2022-01-06 20:46:53 -05:00
|
|
|
state.tryUnify(&testPack, &variadicPack);
|
2021-10-29 16:25:12 -04:00
|
|
|
CHECK(!state.errors.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "variadic_tails_respect_progress")
|
|
|
|
{
|
|
|
|
TypePackVar variadicPack{VariadicTypePack{typeChecker.booleanType}};
|
|
|
|
TypePackVar a{TypePack{{typeChecker.numberType, typeChecker.stringType, typeChecker.booleanType, typeChecker.booleanType}}};
|
|
|
|
TypePackVar b{TypePack{{typeChecker.numberType, typeChecker.stringType}, &variadicPack}};
|
|
|
|
|
2022-01-06 20:46:53 -05:00
|
|
|
state.tryUnify(&b, &a);
|
2021-10-29 16:25:12 -04:00
|
|
|
CHECK(state.errors.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "variadics_should_use_reversed_properly")
|
|
|
|
{
|
|
|
|
CheckResult result = check(R"(
|
|
|
|
--!strict
|
|
|
|
local function f<T>(...: T): ...T
|
|
|
|
return ...
|
|
|
|
end
|
|
|
|
|
|
|
|
local x: string = f(1)
|
|
|
|
)");
|
|
|
|
|
|
|
|
LUAU_REQUIRE_ERROR_COUNT(1, result);
|
|
|
|
TypeMismatch* tm = get<TypeMismatch>(result.errors[0]);
|
|
|
|
REQUIRE(tm);
|
|
|
|
CHECK_EQ(toString(tm->givenType), "number");
|
|
|
|
CHECK_EQ(toString(tm->wantedType), "string");
|
|
|
|
}
|
|
|
|
|
2022-05-13 15:36:37 -04:00
|
|
|
TEST_CASE_FIXTURE(BuiltinsFixture, "cli_41095_concat_log_in_sealed_table_unification")
|
2021-10-29 16:25:12 -04:00
|
|
|
{
|
|
|
|
CheckResult result = check(R"(
|
|
|
|
--!strict
|
|
|
|
table.insert()
|
|
|
|
)");
|
|
|
|
|
|
|
|
LUAU_REQUIRE_ERROR_COUNT(2, result);
|
|
|
|
CHECK_EQ(toString(result.errors[0]), "No overload for function accepts 0 arguments.");
|
2023-02-24 16:49:38 -05:00
|
|
|
if (FFlag::DebugLuauDeferredConstraintResolution)
|
|
|
|
CHECK_EQ(toString(result.errors[1]), "Available overloads: <V>({V}, V) -> (); and <V>({V}, number, V) -> ()");
|
|
|
|
else
|
|
|
|
CHECK_EQ(toString(result.errors[1]), "Available overloads: ({a}, a) -> (); and ({a}, number, a) -> ()");
|
2021-10-29 16:25:12 -04:00
|
|
|
}
|
|
|
|
|
2022-01-06 20:46:53 -05:00
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "free_tail_is_grown_properly")
|
|
|
|
{
|
|
|
|
TypePackId threeNumbers = arena.addTypePack(TypePack{{typeChecker.numberType, typeChecker.numberType, typeChecker.numberType}, std::nullopt});
|
|
|
|
TypePackId numberAndFreeTail = arena.addTypePack(TypePack{{typeChecker.numberType}, arena.addTypePack(TypePackVar{FreeTypePack{TypeLevel{}}})});
|
|
|
|
|
|
|
|
ErrorVec unifyErrors = state.canUnify(numberAndFreeTail, threeNumbers);
|
|
|
|
CHECK(unifyErrors.size() == 0);
|
|
|
|
}
|
|
|
|
|
2022-02-04 11:45:57 -05:00
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "recursive_metatable_getmatchtag")
|
|
|
|
{
|
2023-01-04 15:53:17 -05:00
|
|
|
Type redirect{FreeType{TypeLevel{}}};
|
|
|
|
Type table{TableType{}};
|
|
|
|
Type metatable{MetatableType{&redirect, &table}};
|
|
|
|
redirect = BoundType{&metatable}; // Now we have a metatable that is recursive on the table type
|
|
|
|
Type variant{UnionType{{&metatable, typeChecker.numberType}}};
|
2022-02-04 11:45:57 -05:00
|
|
|
|
|
|
|
state.tryUnify(&metatable, &variant);
|
|
|
|
}
|
|
|
|
|
2022-02-11 14:02:09 -05:00
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "cli_50320_follow_in_any_unification")
|
|
|
|
{
|
|
|
|
TypePackVar free{FreeTypePack{TypeLevel{}}};
|
|
|
|
TypePackVar target{TypePack{}};
|
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
Type func{FunctionType{&free, &free}};
|
2022-02-11 14:02:09 -05:00
|
|
|
|
|
|
|
state.tryUnify(&free, &target);
|
|
|
|
// Shouldn't assert or error.
|
|
|
|
state.tryUnify(&func, typeChecker.anyType);
|
|
|
|
}
|
|
|
|
|
2022-04-07 17:29:01 -04:00
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "txnlog_preserves_type_owner")
|
|
|
|
{
|
2023-01-04 15:53:17 -05:00
|
|
|
TypeId a = arena.addType(Type{FreeType{TypeLevel{}}});
|
2022-04-07 17:29:01 -04:00
|
|
|
TypeId b = typeChecker.numberType;
|
|
|
|
|
|
|
|
state.tryUnify(a, b);
|
|
|
|
state.log.commit();
|
|
|
|
|
|
|
|
CHECK_EQ(a->owningArena, &arena);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "txnlog_preserves_pack_owner")
|
|
|
|
{
|
|
|
|
TypePackId a = arena.addTypePack(TypePackVar{FreeTypePack{TypeLevel{}}});
|
|
|
|
TypePackId b = typeChecker.anyTypePack;
|
|
|
|
|
|
|
|
state.tryUnify(a, b);
|
|
|
|
state.log.commit();
|
|
|
|
|
|
|
|
CHECK_EQ(a->owningArena, &arena);
|
|
|
|
}
|
|
|
|
|
2022-09-29 18:23:10 -04:00
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "metatables_unify_against_shape_of_free_table")
|
|
|
|
{
|
|
|
|
ScopedFastFlag sff("DebugLuauDeferredConstraintResolution", true);
|
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
TableType::Props freeProps{
|
2022-09-29 18:23:10 -04:00
|
|
|
{"foo", {typeChecker.numberType}},
|
|
|
|
};
|
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
TypeId free = arena.addType(TableType{freeProps, std::nullopt, TypeLevel{}, TableState::Free});
|
2022-09-29 18:23:10 -04:00
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
TableType::Props indexProps{
|
2022-09-29 18:23:10 -04:00
|
|
|
{"foo", {typeChecker.stringType}},
|
|
|
|
};
|
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
TypeId index = arena.addType(TableType{indexProps, std::nullopt, TypeLevel{}, TableState::Sealed});
|
2022-09-29 18:23:10 -04:00
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
TableType::Props mtProps{
|
2022-09-29 18:23:10 -04:00
|
|
|
{"__index", {index}},
|
|
|
|
};
|
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
TypeId mt = arena.addType(TableType{mtProps, std::nullopt, TypeLevel{}, TableState::Sealed});
|
2022-09-29 18:23:10 -04:00
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
TypeId target = arena.addType(TableType{TableState::Unsealed, TypeLevel{}});
|
|
|
|
TypeId metatable = arena.addType(MetatableType{target, mt});
|
2022-09-29 18:23:10 -04:00
|
|
|
|
|
|
|
state.tryUnify(metatable, free);
|
|
|
|
state.log.commit();
|
|
|
|
|
|
|
|
REQUIRE_EQ(state.errors.size(), 1);
|
|
|
|
|
|
|
|
std::string expected = "Type '{ @metatable {| __index: {| foo: string |} |}, { } }' could not be converted into '{- foo: number -}'\n"
|
2022-10-14 15:48:41 -04:00
|
|
|
"caused by:\n"
|
|
|
|
" Type 'number' could not be converted into 'string'";
|
2022-09-29 18:23:10 -04:00
|
|
|
CHECK_EQ(toString(state.errors[0]), expected);
|
|
|
|
}
|
|
|
|
|
2022-12-02 13:09:59 -05:00
|
|
|
TEST_CASE_FIXTURE(TryUnifyFixture, "fuzz_tail_unification_issue")
|
|
|
|
{
|
|
|
|
TypePackVar variadicAny{VariadicTypePack{typeChecker.anyType}};
|
|
|
|
TypePackVar packTmp{TypePack{{typeChecker.anyType}, &variadicAny}};
|
|
|
|
TypePackVar packSub{TypePack{{typeChecker.anyType, typeChecker.anyType}, &packTmp}};
|
|
|
|
|
2023-01-04 15:53:17 -05:00
|
|
|
Type freeTy{FreeType{TypeLevel{}}};
|
2022-12-02 13:09:59 -05:00
|
|
|
TypePackVar freeTp{FreeTypePack{TypeLevel{}}};
|
|
|
|
TypePackVar packSuper{TypePack{{&freeTy}, &freeTp}};
|
|
|
|
|
|
|
|
state.tryUnify(&packSub, &packSuper);
|
|
|
|
}
|
|
|
|
|
2023-01-20 15:27:03 -05:00
|
|
|
TEST_CASE_FIXTURE(BuiltinsFixture, "fuzz_unify_any_should_check_log")
|
|
|
|
{
|
|
|
|
CheckResult result = check(R"(
|
|
|
|
repeat
|
|
|
|
_._,_ = nil
|
|
|
|
until _
|
|
|
|
local l0:(any)&(typeof(_)),l0:(any)|(any) = _,_
|
|
|
|
)");
|
|
|
|
|
|
|
|
LUAU_REQUIRE_ERRORS(result);
|
|
|
|
}
|
|
|
|
|
2021-10-29 16:25:12 -04:00
|
|
|
TEST_SUITE_END();
|