Add FFlag

This commit is contained in:
JohnnyMorganz 2023-09-21 19:36:32 -05:00
parent 0ab3db5c29
commit 1cde3871e0
3 changed files with 13 additions and 0 deletions

View file

@ -11,6 +11,7 @@
LUAU_FASTINT(LuauTableTypeMaximumStringifierLength) LUAU_FASTINT(LuauTableTypeMaximumStringifierLength)
LUAU_FASTINT(LuauTypeMaximumStringifierLength) LUAU_FASTINT(LuauTypeMaximumStringifierLength)
LUAU_FASTFLAG(LuauToStringSimpleCompositeTypesSingleLine)
namespace Luau namespace Luau
{ {
@ -39,6 +40,12 @@ struct ToStringNameMap
struct ToStringOptions struct ToStringOptions
{ {
ToStringOptions(bool exhaustive = false)
: exhaustive(exhaustive)
, compositeTypesSingleLineLimit(FFlag::LuauToStringSimpleCompositeTypesSingleLine.value ? 5 : 0)
{
}
bool exhaustive = false; // If true, we produce complete output rather than comprehensible output bool exhaustive = false; // If true, we produce complete output rather than comprehensible output
bool useLineBreaks = false; // If true, we insert new lines to separate long results such as table entries/metatable. bool useLineBreaks = false; // If true, we insert new lines to separate long results such as table entries/metatable.
bool functionTypeArguments = false; // If true, output function type argument names when they are available bool functionTypeArguments = false; // If true, output function type argument names when they are available

View file

@ -17,6 +17,7 @@
LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution) LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution)
LUAU_FASTFLAGVARIABLE(LuauToStringPrettifyLocation, false) LUAU_FASTFLAGVARIABLE(LuauToStringPrettifyLocation, false)
LUAU_FASTFLAGVARIABLE(LuauToStringSimpleCompositeTypesSingleLine, false)
/* /*
* Enables increasing levels of verbosity for Luau type names when stringifying. * Enables increasing levels of verbosity for Luau type names when stringifying.

View file

@ -216,6 +216,7 @@ TEST_CASE_FIXTURE(Fixture, "functions_are_always_parenthesized_in_unions_or_inte
TEST_CASE_FIXTURE(Fixture, "simple_intersections_printed_on_one_line") TEST_CASE_FIXTURE(Fixture, "simple_intersections_printed_on_one_line")
{ {
ScopedFastFlag sff{"LuauToStringSimpleCompositeTypesSingleLine", true};
CheckResult result = check(R"( CheckResult result = check(R"(
local a: string & number local a: string & number
)"); )");
@ -228,6 +229,7 @@ TEST_CASE_FIXTURE(Fixture, "simple_intersections_printed_on_one_line")
TEST_CASE_FIXTURE(Fixture, "complex_intersections_printed_on_multiple_lines") TEST_CASE_FIXTURE(Fixture, "complex_intersections_printed_on_multiple_lines")
{ {
ScopedFastFlag sff{"LuauToStringSimpleCompositeTypesSingleLine", true};
CheckResult result = check(R"( CheckResult result = check(R"(
local a: string & number & boolean local a: string & number & boolean
)"); )");
@ -246,6 +248,7 @@ TEST_CASE_FIXTURE(Fixture, "complex_intersections_printed_on_multiple_lines")
TEST_CASE_FIXTURE(Fixture, "overloaded_functions_always_printed_on_multiple_lines") TEST_CASE_FIXTURE(Fixture, "overloaded_functions_always_printed_on_multiple_lines")
{ {
ScopedFastFlag sff{"LuauToStringSimpleCompositeTypesSingleLine", true};
CheckResult result = check(R"( CheckResult result = check(R"(
local a: ((string) -> string) & ((number) -> number) local a: ((string) -> string) & ((number) -> number)
)"); )");
@ -262,6 +265,7 @@ TEST_CASE_FIXTURE(Fixture, "overloaded_functions_always_printed_on_multiple_line
TEST_CASE_FIXTURE(Fixture, "simple_unions_printed_on_one_line") TEST_CASE_FIXTURE(Fixture, "simple_unions_printed_on_one_line")
{ {
ScopedFastFlag sff{"LuauToStringSimpleCompositeTypesSingleLine", true};
CheckResult result = check(R"( CheckResult result = check(R"(
local a: number | boolean local a: number | boolean
)"); )");
@ -274,6 +278,7 @@ TEST_CASE_FIXTURE(Fixture, "simple_unions_printed_on_one_line")
TEST_CASE_FIXTURE(Fixture, "complex_unions_printed_on_multiple_lines") TEST_CASE_FIXTURE(Fixture, "complex_unions_printed_on_multiple_lines")
{ {
ScopedFastFlag sff{"LuauToStringSimpleCompositeTypesSingleLine", true};
CheckResult result = check(R"( CheckResult result = check(R"(
local a: string | number | boolean local a: string | number | boolean
)"); )");