mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-06 12:57:14 +03:00
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:
parent
ed65b44df3
commit
fe0dc216f0
@ -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[] = [];
|
||||
|
11
packages/pyright-internal/src/tests/samples/solver39.py
Normal file
11
packages/pyright-internal/src/tests/samples/solver39.py
Normal 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)
|
@ -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']);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user