mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Better support format, types
This commit is contained in:
parent
a1349a4c04
commit
f4a16d7502
2 changed files with 13 additions and 1 deletions
|
@ -1072,7 +1072,7 @@ static std::vector<TypeId> parseFormatString(TypeChecker& typechecker, const cha
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// we just ignore all characters (including flags/precision) up until first alphabetic character
|
// we just ignore all characters (including flags/precision) up until first alphabetic character
|
||||||
while (i < size && !(data[i] > 0 && isalpha(data[i])))
|
while (i < size && !(data[i] > 0 && (isalpha(data[i])) || data[i] == '*'))
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i == size)
|
if (i == size)
|
||||||
|
@ -1080,6 +1080,8 @@ static std::vector<TypeId> parseFormatString(TypeChecker& typechecker, const cha
|
||||||
|
|
||||||
if (data[i] == 'q' || data[i] == 's')
|
if (data[i] == 'q' || data[i] == 's')
|
||||||
result.push_back(typechecker.stringType);
|
result.push_back(typechecker.stringType);
|
||||||
|
else if (data[i] == '*')
|
||||||
|
result.push_back(typechecker.errorRecoveryType(typechecker.anyType));
|
||||||
else if (strchr(options, data[i]))
|
else if (strchr(options, data[i]))
|
||||||
result.push_back(typechecker.numberType);
|
result.push_back(typechecker.numberType);
|
||||||
else
|
else
|
||||||
|
|
|
@ -556,6 +556,16 @@ TEST_CASE_FIXTURE(BuiltinsFixture, "string_format_correctly_ordered_types")
|
||||||
CHECK_EQ(tm->givenType, typeChecker.numberType);
|
CHECK_EQ(tm->givenType, typeChecker.numberType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE_FIXTURE(BuiltinsFixture, "string_format_tostring_specifier")
|
||||||
|
{
|
||||||
|
CheckResult result = check(R"(
|
||||||
|
--!strict
|
||||||
|
string.format("%* %* %* %*", "string", 1, true, function() end)
|
||||||
|
)");
|
||||||
|
|
||||||
|
LUAU_REQUIRE_NO_ERRORS(result);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE_FIXTURE(BuiltinsFixture, "xpcall")
|
TEST_CASE_FIXTURE(BuiltinsFixture, "xpcall")
|
||||||
{
|
{
|
||||||
CheckResult result = check(R"(
|
CheckResult result = check(R"(
|
||||||
|
|
Loading…
Add table
Reference in a new issue