Skip to content

Commit

Permalink
Fixed bug that can result in incorrect type evaluation behaviors if a…
Browse files Browse the repository at this point in the history
… call to `type` is used within a loop. This addresses microsoft#9023. (microsoft#9024)
  • Loading branch information
erictraut authored Sep 18, 2024
1 parent a56a4ec commit c58d75c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/pyright-internal/src/analyzer/typeEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10103,7 +10103,8 @@ export function createTypeEvaluator(
// The one-parameter form of "type" returns the class
// for the specified object.
if (expandedCallType.shared.name === 'type' && argList.length === 1) {
const argType = getTypeOfArg(argList[0], /* inferenceContext */ undefined).type;
const argTypeResult = getTypeOfArg(argList[0], /* inferenceContext */ undefined);
const argType = argTypeResult.type;
const returnType = mapSubtypes(argType, (subtype) => {
if (isNever(subtype)) {
return subtype;
Expand All @@ -10124,7 +10125,7 @@ export function createTypeEvaluator(
]);
});

return { returnType };
return { returnType, isTypeIncomplete: argTypeResult.isIncomplete };
}

if (argList.length >= 2) {
Expand Down

0 comments on commit c58d75c

Please sign in to comment.