Skip to content
3 changes: 2 additions & 1 deletion Analysis/src/TypeFunctionRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <vector>

LUAU_DYNAMIC_FASTINT(LuauTypeFunctionSerdeIterationLimit)
LUAU_FASTFLAGVARIABLE(LuauRenameClassToExtern)

namespace Luau
{
Expand Down Expand Up @@ -288,7 +289,7 @@ static std::string getTag(lua_State* L, TypeFunctionTypeId ty)
else if (get<TypeFunctionFunctionType>(ty))
return "function";
else if (get<TypeFunctionExternType>(ty))
return "class";
return (FFlag::LuauRenameClassToExtern ? "extern" : "class");
else if (get<TypeFunctionGenericType>(ty))
return "generic";

Expand Down
35 changes: 35 additions & 0 deletions tests/TypeFunction.user.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ LUAU_FASTFLAG(LuauEagerGeneralization4)
LUAU_FASTFLAG(LuauTypeFunNoScopeMapRef)
LUAU_FASTFLAG(LuauInstantiateResolvedTypeFunctions)

LUAU_FASTFLAG(LuauRenameClassToExtern)

TEST_SUITE_BEGIN("UserDefinedTypeFunctionTests");

TEST_CASE_FIXTURE(BuiltinsFixture, "udtf_nil_serialization_works")
Expand Down Expand Up @@ -2449,6 +2451,39 @@ end
CHECK(toString(result.errors[0]) == R"(Redefinition of type 't0', previously defined at line 2)");
}

TEST_CASE_FIXTURE(BuiltinsFixture, "udtf_extern_tag")
{
ScopedFastFlag sff[]{
{FFlag::LuauSolverV2, true},
{FFlag::LuauRenameClassToExtern, true}
};

loadDefinition(R"(
declare extern type CustomExternType with
function testFunc(self): number
end
)");

CheckResult result = check(R"(
--!strict
type function tyFunc(arg: type)
if (arg:is("extern")) then
return arg
end
-- this should never be returned
return types.boolean
end

type a = tyFunc<CustomExternType>
)");

auto test = requireTypeAlias("a");
// If it's not an ExternType it will fail.
LUAU_ASSERT( test->ty.get_if<ExternType>() );

LUAU_REQUIRE_NO_ERRORS(result);
}

TEST_CASE_FIXTURE(BuiltinsFixture, "udtf_fuzz_environment_scope_crash")
{
ScopedFastFlag newSolver{FFlag::LuauSolverV2, true};
Expand Down
Loading