Fixed bug that results in a false positive error under certain circumstances when passing an overloaded function as an argument to a call. This addresses #8632. (#8644)

This commit is contained in:
Eric Traut 2024-08-03 01:12:51 -06:00 committed by GitHub
parent ed65b44df3
commit fe0dc216f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 0 deletions

View File

@ -23979,6 +23979,15 @@ export function createTypeEvaluator(
}
if (isOverloadedFunction(concreteSrcType)) {
// If this is the first pass of an argument assignment, skip
// all attempts to assign an overloaded function to a function
// because we probably don't have enough information to properly
// filter the overloads at this time. We will do this work on
// subsequent passes.
if ((flags & AssignTypeFlags.ArgAssignmentFirstPass) !== 0) {
return true;
}
// Find all of the overloaded functions that match the parameters.
const overloads = OverloadedFunctionType.getOverloads(concreteSrcType);
const filteredOverloads: FunctionType[] = [];

View File

@ -0,0 +1,11 @@
# This sample tests the case where an overloaded function is passed as
# an argument and the overloads cannot be filtered during the first
# pass through the arguments.
from functools import reduce
from operator import getitem
from typing import Any
def deep_getitem(data: dict[str, Any], attr: str) -> Any:
return reduce(getitem, attr.split("."), data)

View File

@ -795,6 +795,12 @@ test('Solver38', () => {
TestUtils.validateResults(analysisResults, 0);
});
test('Solver39', () => {
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['solver39.py']);
TestUtils.validateResults(analysisResults, 0);
});
test('SolverScoring1', () => {
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['solverScoring1.py']);