Fix singleton parameters in overloaded functions

This commit is contained in:
Math 2025-02-27 13:14:27 -03:00
parent 66b00f6980
commit 5d4d7b4625

View file

@ -2031,13 +2031,23 @@ InferencePack ConstraintGenerator::checkPack(const ScopePtr& scope, AstExprCall*
}
else if (i < exprArgs.size() - 1 || !(arg->is<AstExprCall>() || arg->is<AstExprVarargs>()))
{
auto [ty, refinement] = check(scope, arg, /*expectedType*/ std::nullopt, /*forceSingleton*/ false, /*generalize*/ false);
std::optional<TypeId> expectedType;
if (i < expectedTypesForCall.size())
{
expectedType = expectedTypesForCall[i];
}
auto [ty, refinement] = check(scope, arg, expectedType, /*forceSingleton*/ false, /*generalize*/ false);
args.push_back(ty);
argumentRefinements.push_back(refinement);
}
else
{
auto [tp, refis] = checkPack(scope, arg, {});
std::vector<std::optional<Luau::TypeId>> expectedTypes = {};
if (i < expectedTypesForCall.size())
{
expectedTypes.insert(expectedTypes.end(), expectedTypesForCall.begin() + i, expectedTypesForCall.end());
}
auto [tp, refis] = checkPack(scope, arg, expectedTypes);
argTail = tp;
argumentRefinements.insert(argumentRefinements.end(), refis.begin(), refis.end());
}