Fix the order of the arguments being inputted into result.append in print() from the Type Function Runtime (#1676)

---

Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com>
This commit is contained in:
karl-police 2025-02-20 21:32:47 +01:00 committed by GitHub
parent 14ccae9b44
commit 29a5198055
Signed by: DevComp
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 1 deletions

View file

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

View file

@ -10,6 +10,7 @@ using namespace Luau;
LUAU_FASTFLAG(LuauSolverV2) LUAU_FASTFLAG(LuauSolverV2)
LUAU_FASTFLAG(DebugLuauEqSatSimplification) LUAU_FASTFLAG(DebugLuauEqSatSimplification)
LUAU_FASTFLAG(LuauUserTypeFunTypeofReturnsType) LUAU_FASTFLAG(LuauUserTypeFunTypeofReturnsType)
LUAU_FASTFLAG(LuauTypeFunPrintFix)
TEST_SUITE_BEGIN("UserDefinedTypeFunctionTests"); TEST_SUITE_BEGIN("UserDefinedTypeFunctionTests");
@ -1885,4 +1886,24 @@ local _:test<number>
CHECK(toString(result.errors[0]) == R"(type)"); 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>
)");
LUAU_REQUIRE_ERROR_COUNT(1, result);
// It should be \t and not \x1
CHECK_EQ("1\t2", toString(result.errors[0]));
}
TEST_SUITE_END(); TEST_SUITE_END();