From 8ef45854f78d4c60a01d059124b8f1082ce0395a Mon Sep 17 00:00:00 2001 From: Kampfkarren Date: Wed, 27 Jul 2022 17:59:21 -0700 Subject: [PATCH] Add FFlag for %* --- VM/src/lstrlib.cpp | 15 +++++++++++++++ tests/Conformance.test.cpp | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/VM/src/lstrlib.cpp b/VM/src/lstrlib.cpp index 49158f27..20937727 100644 --- a/VM/src/lstrlib.cpp +++ b/VM/src/lstrlib.cpp @@ -8,6 +8,9 @@ #include #include +LUAU_FASTFLAG(LuauInterpolatedStringBaseSupport) +LUAU_FASTFLAGVARIABLE(LuauTostringFormatSpecifier, false); + /* macro to `unsign' a character */ #define uchar(c) ((unsigned char)(c)) @@ -1034,6 +1037,18 @@ static int str_format(lua_State* L) } case '*': { + if (!FFlag::LuauTostringFormatSpecifier) + { + if (FFlag::LuauInterpolatedStringBaseSupport) + { + luaL_error(L, "interpolated strings are enabled, but the '*' format specifier is not. this is a configuration bug."); + break; + } + + luaL_error(L, "invalid option '%%*' to 'format'"); + break; + } + if (formatItemSize != 1) { luaL_error(L, "'%%*' does not take a form"); diff --git a/tests/Conformance.test.cpp b/tests/Conformance.test.cpp index 21d1782e..2880c4d7 100644 --- a/tests/Conformance.test.cpp +++ b/tests/Conformance.test.cpp @@ -291,12 +291,16 @@ TEST_CASE("Clear") TEST_CASE("Strings") { + ScopedFastFlag sff{"LuauTostringFormatSpecifier", true}; + runConformance("strings.lua"); } TEST_CASE("StringInterp") { - ScopedFastFlag sff{"LuauInterpolatedStringBaseSupport", true}; + ScopedFastFlag sffInterpStrings{"LuauInterpolatedStringBaseSupport", true}; + ScopedFastFlag sffTostringFormat{"LuauTostringFormatSpecifier", true}; + runConformance("stringinterp.lua"); }