Skip to content

Commit

Permalink
Fixed a bug that results in a crash when attempting to use a member a…
Browse files Browse the repository at this point in the history
…ccess expression where the LHS is a TypeVarTuple. This addresses microsoft/pylance-release#4630.
  • Loading branch information
msfterictraut committed Jul 19, 2023
1 parent 1d558e0 commit b953f79
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions packages/pyright-internal/src/analyzer/typeEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4876,7 +4876,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
}
}

const getTypeOfNoneBase = (subtype: NoneType) => {
function getTypeOfNoneBase(subtype: NoneType) {
if (noneType && isInstantiableClass(noneType)) {
if (TypeBase.isInstance(subtype)) {
return getTypeOfObjectMember(
Expand All @@ -4891,7 +4891,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
}
}
return undefined;
};
}

if (isParamSpec(baseType) && baseType.paramSpecAccess) {
baseType = makeTopLevelTypeVarsConcrete(baseType);
Expand Down Expand Up @@ -4956,16 +4956,20 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
return { type: UnknownType.create(/* isIncomplete */ true), isIncomplete: true };
}

return getTypeOfMemberAccessWithBaseType(
node,
{
type: makeTopLevelTypeVarsConcrete(baseType),
bindToType: baseType,
isIncomplete,
},
usage,
EvaluatorFlags.None
);
if (!baseType.details.isVariadic) {
return getTypeOfMemberAccessWithBaseType(
node,
{
type: makeTopLevelTypeVarsConcrete(baseType),
bindToType: baseType,
isIncomplete,
},
usage,
EvaluatorFlags.None
);
}

break;
}

case TypeCategory.Class: {
Expand Down

0 comments on commit b953f79

Please sign in to comment.