From 7d11e464ad5976ce202dc2492014d309c35de907 Mon Sep 17 00:00:00 2001 From: karl-police Date: Wed, 23 Jul 2025 17:11:49 +0200 Subject: [PATCH 1/6] Rename "class" to "extern" locked behind a debug flag, through a tenary operator --- Analysis/src/TypeFunctionRuntime.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Analysis/src/TypeFunctionRuntime.cpp b/Analysis/src/TypeFunctionRuntime.cpp index 5a6657e0b..94b718d02 100644 --- a/Analysis/src/TypeFunctionRuntime.cpp +++ b/Analysis/src/TypeFunctionRuntime.cpp @@ -22,6 +22,7 @@ LUAU_DYNAMIC_FASTINT(LuauTypeFunctionSerdeIterationLimit) LUAU_FASTFLAGVARIABLE(LuauTypeFunOptional) +LUAU_FASTFLAGVARIABLE(DebugLuauRenameClassToExtern) namespace Luau { @@ -289,7 +290,7 @@ static std::string getTag(lua_State* L, TypeFunctionTypeId ty) else if (get(ty)) return "function"; else if (get(ty)) - return "class"; + return (FFlag::DebugLuauRenameClassToExtern ? "extern" : "class"); else if (get(ty)) return "generic"; From bda1f16b86db106708c9715cc235d693c26128a4 Mon Sep 17 00:00:00 2001 From: karl-police Date: Wed, 23 Jul 2025 17:14:40 +0200 Subject: [PATCH 2/6] Update TypeFunction.user.test.cpp --- tests/TypeFunction.user.test.cpp | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/TypeFunction.user.test.cpp b/tests/TypeFunction.user.test.cpp index 0c8871170..85cb4cb35 100644 --- a/tests/TypeFunction.user.test.cpp +++ b/tests/TypeFunction.user.test.cpp @@ -13,6 +13,8 @@ LUAU_FASTFLAG(LuauEagerGeneralization4) LUAU_FASTFLAG(LuauTableLiteralSubtypeSpecificCheck2) LUAU_FASTFLAG(LuauStuckTypeFunctionsStillDispatch) LUAU_FASTFLAG(LuauTypeFunctionSerializeFollowMetatable) +LUAU_FASTFLAG(LuauDeclareExternType) +LUAU_FASTFLAG(DebugLuauRenameClassToExtern) TEST_SUITE_BEGIN("UserDefinedTypeFunctionTests"); @@ -2486,4 +2488,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::LuauDeclareExternType, true}, + {FFlag::DebugLuauRenameClassToExtern, true} + }; + + loadDefinition(R"( + declare extern type CustomExternType with + function testFunc(self): number + end + )"); + + CheckResult result = check(R"( + --!strict + type function tyFunc(arg: type) + print(arg.tag) + if (arg:is("extern")) then + return arg + end + -- this should never be returned + return types.boolean + end + + type a = tyFunc + )"); + + auto test = requireTypeAlias("a"); + // If it's not an ExternType it will fail. + LUAU_ASSERT( test->ty.get_if() ); + + LUAU_REQUIRE_NO_ERRORS(result); +} + TEST_SUITE_END(); From 5a6cdae70b2768c6364a1bb6edb476e63e7f49e4 Mon Sep 17 00:00:00 2001 From: karl-police Date: Wed, 23 Jul 2025 17:16:38 +0200 Subject: [PATCH 3/6] Update TypeFunction.user.test.cpp --- tests/TypeFunction.user.test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/TypeFunction.user.test.cpp b/tests/TypeFunction.user.test.cpp index 85cb4cb35..50fcb372d 100644 --- a/tests/TypeFunction.user.test.cpp +++ b/tests/TypeFunction.user.test.cpp @@ -2505,7 +2505,6 @@ TEST_CASE_FIXTURE(BuiltinsFixture, "udtf_extern_tag") CheckResult result = check(R"( --!strict type function tyFunc(arg: type) - print(arg.tag) if (arg:is("extern")) then return arg end From 64255cb12ac5cb5ca2717fab761e7ca88412af95 Mon Sep 17 00:00:00 2001 From: karl-police Date: Fri, 22 Aug 2025 01:11:21 +0200 Subject: [PATCH 4/6] Update TypeFunctionRuntime.cpp --- Analysis/src/TypeFunctionRuntime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Analysis/src/TypeFunctionRuntime.cpp b/Analysis/src/TypeFunctionRuntime.cpp index e72153ed5..c3dd55e61 100644 --- a/Analysis/src/TypeFunctionRuntime.cpp +++ b/Analysis/src/TypeFunctionRuntime.cpp @@ -289,7 +289,7 @@ static std::string getTag(lua_State* L, TypeFunctionTypeId ty) else if (get(ty)) return "function"; else if (get(ty)) - return (FFlag::DebugLuauRenameClassToExtern ? "extern" : "class"); + return (FFlag::LuauRenameClassToExtern ? "extern" : "class"); else if (get(ty)) return "generic"; From 1030153eb112d368cf465bbfb7c3a45f9351dae8 Mon Sep 17 00:00:00 2001 From: karl-police Date: Fri, 22 Aug 2025 01:11:48 +0200 Subject: [PATCH 5/6] Update TypeFunction.user.test.cpp --- tests/TypeFunction.user.test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/TypeFunction.user.test.cpp b/tests/TypeFunction.user.test.cpp index 4e1e30c47..9861be65b 100644 --- a/tests/TypeFunction.user.test.cpp +++ b/tests/TypeFunction.user.test.cpp @@ -12,7 +12,7 @@ LUAU_FASTFLAG(DebugLuauEqSatSimplification) LUAU_FASTFLAG(LuauEagerGeneralization4) LUAU_FASTFLAG(LuauTrackFreeInteriorTypePacks) LUAU_FASTFLAG(LuauResetConditionalContextProperly) -LUAU_FASTFLAG(DebugLuauRenameClassToExtern) +LUAU_FASTFLAG(LuauRenameClassToExtern) TEST_SUITE_BEGIN("UserDefinedTypeFunctionTests"); @@ -2457,7 +2457,7 @@ TEST_CASE_FIXTURE(BuiltinsFixture, "udtf_extern_tag") ScopedFastFlag sff[]{ {FFlag::LuauSolverV2, true}, {FFlag::LuauDeclareExternType, true}, - {FFlag::DebugLuauRenameClassToExtern, true} + {FFlag::LuauRenameClassToExtern, true} }; loadDefinition(R"( From 5810b3251677425a9573c8575e0db31a4b927f90 Mon Sep 17 00:00:00 2001 From: karl-police Date: Fri, 22 Aug 2025 01:14:29 +0200 Subject: [PATCH 6/6] Update TypeFunction.user.test.cpp --- tests/TypeFunction.user.test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/TypeFunction.user.test.cpp b/tests/TypeFunction.user.test.cpp index 9861be65b..ed715f68a 100644 --- a/tests/TypeFunction.user.test.cpp +++ b/tests/TypeFunction.user.test.cpp @@ -2456,7 +2456,6 @@ TEST_CASE_FIXTURE(BuiltinsFixture, "udtf_extern_tag") { ScopedFastFlag sff[]{ {FFlag::LuauSolverV2, true}, - {FFlag::LuauDeclareExternType, true}, {FFlag::LuauRenameClassToExtern, true} };