Fix type function print append function argument order

This commit is contained in:
karl-police 2025-02-20 17:48:12 +01:00
parent 9c198413ec
commit 11f4cd90af
2 changed files with 26 additions and 1 deletions

View file

@ -15,6 +15,7 @@
LUAU_DYNAMIC_FASTINT(LuauTypeFunctionSerdeIterationLimit)
LUAU_FASTFLAGVARIABLE(LuauUserTypeFunTypeofReturnsType)
LUAU_FASTFLAGVARIABLE(LuauTypeFunPrintFix)
namespace Luau
{
@ -1610,7 +1611,12 @@ static int print(lua_State* L)
size_t l = 0;
const char* s = luaL_tolstring(L, i, &l); // convert to string using __tostring et al
if (i > 1)
result.append('\t', 1);
{
if (FFlag::LuauTypeFunPrintFix)
result.append(1, '\t');
else
result.append('\t', 1);
}
result.append(s, l);
lua_pop(L, 1);
}

View file

@ -10,6 +10,7 @@ using namespace Luau;
LUAU_FASTFLAG(LuauSolverV2)
LUAU_FASTFLAG(DebugLuauEqSatSimplification)
LUAU_FASTFLAG(LuauUserTypeFunTypeofReturnsType)
LUAU_FASTFLAG(LuauTypeFunPrintFix)
TEST_SUITE_BEGIN("UserDefinedTypeFunctionTests");
@ -1885,4 +1886,22 @@ local _:test<number>
CHECK(toString(result.errors[0]) == R"(type)");
}
TEST_CASE_FIXTURE(BuiltinsFixture, "udtf_print_tab_char_fix")
{
ScopedFastFlag sffs[] = {{FFlag::LuauSolverV2, true}, {FFlag::LuauTypeFunPrintFix, true}};
CheckResult result = check(R"(
type function test(t)
print(1,2)
return t
end
local _:test<number>
)");
// It should be \t and not \x1
CHECK_EQ("1\t2", toString(result.errors[0]));
}
TEST_SUITE_END();