mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-06 12:57:14 +03:00
Fixed bug that results in false positive error under certain circumstances when solving type variables that involve literal values. This addresses #8133 and #8048. (#8603)
This commit is contained in:
parent
74345cc15f
commit
6913347aa8
@ -24859,11 +24859,21 @@ export function createTypeEvaluator(
|
||||
let doSpecializationStep = false;
|
||||
|
||||
if ((flags & AssignTypeFlags.OverloadOverlap) === 0) {
|
||||
const isFirstPass = (flags & AssignTypeFlags.ArgAssignmentFirstPass) !== 0;
|
||||
|
||||
if ((flags & AssignTypeFlags.ReverseTypeVarMatching) === 0) {
|
||||
specializedDestType = applySolvedTypeVars(destType, destTypeVarContext, { useLowerBoundOnly: true });
|
||||
if (!isFirstPass) {
|
||||
specializedDestType = applySolvedTypeVars(destType, destTypeVarContext, {
|
||||
useLowerBoundOnly: true,
|
||||
});
|
||||
}
|
||||
doSpecializationStep = requiresSpecialization(specializedDestType);
|
||||
} else {
|
||||
specializedSrcType = applySolvedTypeVars(srcType, srcTypeVarContext, { useLowerBoundOnly: true });
|
||||
if (!isFirstPass) {
|
||||
specializedSrcType = applySolvedTypeVars(srcType, srcTypeVarContext, {
|
||||
useLowerBoundOnly: true,
|
||||
});
|
||||
}
|
||||
doSpecializationStep = requiresSpecialization(specializedSrcType);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
from typing import Callable, Generic, Literal, TypeVar
|
||||
|
||||
|
||||
FileChanges = dict[str, Literal["created", "edited", "removed"]]
|
||||
|
||||
changes: FileChanges = {}
|
||||
@ -66,6 +65,4 @@ def func8(a: _T, b: Callable[[list[_T]], None]) -> _T:
|
||||
def func9(v: Callable[[list[int]], None]):
|
||||
func8(b=v, a=1)
|
||||
|
||||
# This should also type check without error, but it doesn't currently.
|
||||
# See issue #8048.
|
||||
# func8(a=1, b=v)
|
||||
func8(a=1, b=v)
|
||||
|
Loading…
Reference in New Issue
Block a user