mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Fixed bug that results in duplicate and (contradictory) diagnostic outputs in certain cases where reveal_type
is used in a loop.
This commit is contained in:
parent
a0af8c5c8c
commit
aad860332e
@ -8321,32 +8321,37 @@ export function createTypeEvaluator(
|
||||
const exprString = ParseTreeUtils.printExpression(arg0Value);
|
||||
const typeString = printType(type, { expandTypeAlias: true });
|
||||
|
||||
if (expectedText !== undefined) {
|
||||
if (expectedText !== typeString) {
|
||||
addError(
|
||||
LocMessage.revealTypeExpectedTextMismatch().format({
|
||||
expected: expectedText,
|
||||
received: typeString,
|
||||
}),
|
||||
expectedTextNode ?? arg0Value
|
||||
);
|
||||
if (!typeResult.isIncomplete) {
|
||||
if (expectedText !== undefined) {
|
||||
if (expectedText !== typeString) {
|
||||
addError(
|
||||
LocMessage.revealTypeExpectedTextMismatch().format({
|
||||
expected: expectedText,
|
||||
received: typeString,
|
||||
}),
|
||||
expectedTextNode ?? arg0Value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (expectedRevealType) {
|
||||
if (!isTypeSame(expectedRevealType, type, { ignorePseudoGeneric: true })) {
|
||||
const expectedRevealTypeText = printType(expectedRevealType);
|
||||
addError(
|
||||
LocMessage.revealTypeExpectedTypeMismatch().format({
|
||||
expected: expectedRevealTypeText,
|
||||
received: typeString,
|
||||
}),
|
||||
expectedRevealTypeNode ?? arg0Value
|
||||
);
|
||||
if (expectedRevealType) {
|
||||
if (!isTypeSame(expectedRevealType, type, { ignorePseudoGeneric: true })) {
|
||||
const expectedRevealTypeText = printType(expectedRevealType);
|
||||
addError(
|
||||
LocMessage.revealTypeExpectedTypeMismatch().format({
|
||||
expected: expectedRevealTypeText,
|
||||
received: typeString,
|
||||
}),
|
||||
expectedRevealTypeNode ?? arg0Value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addInformation(LocAddendum.typeOfSymbol().format({ name: exprString, type: typeString }), node.arguments[0]);
|
||||
addInformation(
|
||||
LocAddendum.typeOfSymbol().format({ name: exprString, type: typeString }),
|
||||
node.arguments[0]
|
||||
);
|
||||
}
|
||||
|
||||
return { type, isIncomplete: typeResult.isIncomplete };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user