mirror of
https://github.com/microsoft/pyright.git
synced 2024-11-20 09:39:23 +03:00
Fixed bug that results in a spurious error when evaluating a quoted (forward reference) type expression that includes an index expression within a TypeAlias
definition. This addresses https://github.com/microsoft/pylance-release/issues/6072.
This commit is contained in:
parent
3c70b4e0d1
commit
bee1d912fd
@ -19499,6 +19499,16 @@ export function createTypeEvaluator(
|
||||
continue;
|
||||
}
|
||||
|
||||
// Forward-declared type annotation expressions need to be be evaluated
|
||||
// in context so they have the appropriate flags set. Most of these cases
|
||||
// will have been detected above when calling getParentAnnotationNode,
|
||||
// but TypeAlias expressions are not handled there.
|
||||
const stringEnclosure = ParseTreeUtils.getParentNodeOfType(parent, ParseNodeType.StringList);
|
||||
if (stringEnclosure) {
|
||||
nodeToEvaluate = stringEnclosure as StringListNode;
|
||||
continue;
|
||||
}
|
||||
|
||||
// The left expression of a call or member access expression is not generally contextual.
|
||||
if (parent.nodeType === ParseNodeType.Call || parent.nodeType === ParseNodeType.MemberAccess) {
|
||||
if (nodeToEvaluate === parent.leftExpression) {
|
||||
@ -19525,15 +19535,7 @@ export function createTypeEvaluator(
|
||||
// The base expression of an index expression is not contextual.
|
||||
if (nodeToEvaluate === parent.baseExpression) {
|
||||
flags = EvaluatorFlags.IndexBaseDefaults;
|
||||
break;
|
||||
}
|
||||
} else if (parent.nodeType === ParseNodeType.StringList && nodeToEvaluate === parent.typeAnnotation) {
|
||||
// Forward-declared type annotation expressions need to be be evaluated
|
||||
// in context so they have the appropriate flags set. Most of these cases
|
||||
// will have been detected above when calling getParentAnnotationNode,
|
||||
// but TypeAlias expressions are not handled there.
|
||||
nodeToEvaluate = parent;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isExpressionNode(parent)) {
|
||||
|
Loading…
Reference in New Issue
Block a user