mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-26 02:38:31 +03:00
Issue8054 (#8055)
* Fixed bug that results in a false negative when solving a type variable that involves an invariant context. * Fixed a bug that can result in incorrect type inference for a subexpression that is part of an assignment expression if executed with an inference context (bidirectional type inference). This addresses #8054.
This commit is contained in:
parent
5ac25c8256
commit
67fd972213
@ -14622,11 +14622,11 @@ export function createTypeEvaluator(
|
||||
assert(node.nodeType === ParseNodeType.ComprehensionIf);
|
||||
|
||||
// Evaluate the test expression to validate it and mark symbols
|
||||
// as referenced. Don't bother doing this if we're in speculative
|
||||
// mode because it doesn't affect the element type.
|
||||
if (!isSpeculativeModeInUse(node.testExpression)) {
|
||||
getTypeOfExpression(node.testExpression);
|
||||
}
|
||||
// as referenced. This doesn't affect the type of the evalauted
|
||||
// comprehension, but it is important for evaluating intermediate
|
||||
// expressions such as assignment expressions that can affect other
|
||||
// subexpressions.
|
||||
getTypeOfExpression(node.testExpression);
|
||||
}
|
||||
|
||||
return isIncomplete;
|
||||
@ -19721,7 +19721,7 @@ export function createTypeEvaluator(
|
||||
}
|
||||
|
||||
case ParseNodeType.AssignmentExpression: {
|
||||
getTypeOfExpression(curNode);
|
||||
evaluateTypesForExpressionInContext(curNode);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ class ClassA:
|
||||
output: str
|
||||
|
||||
|
||||
def func1(foo: ClassA):
|
||||
foo.output = "".join(
|
||||
stripped for line in foo.input.splitlines() if (stripped := line.strip())
|
||||
def func1(a: ClassA, x: str):
|
||||
a.output = x.join(
|
||||
stripped for line in a.input.splitlines() if (stripped := line.strip())
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user