luau
luau copied to clipboard
FunctionRequiresSelf not triggered if the last argument is a function call
Debugging the code seems that if the last argument is a function call the FunctionRequiresSelf is not triggered in favor of CountMismatch error.
TypeChecker::checkExprPackHelper()
is calling TypeChecker::checkExprList()
to get the list of the arguments types but seems that checkExprList is treating the last argument differently without adding it to the returned typepack if it's a function call:
if (i == lastIndex && (expr->is<AstExprCall>() || expr->is<AstExprVarargs>()))
After that TypeChecker::checkExprPackHelper()
will call handleSelfCallMismatch()
, and then checkArgumentList() will detect a CountMismatch error that avoid to trigger a FunctionRequireSelf error:
checkArgumentList(scope, *expr.func, editedState, editedArgPack, ftv->argTypes, editedArgLocations);
if (editedState.errors.empty())
{
editedState.log.commit();
reportError(TypeError{expr.location, FunctionRequiresSelf{}});
}