From fdca53a9399b1be68cb70d11a75e318d464cccf6 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Tue, 28 Jul 2020 08:28:29 -0700 Subject: [PATCH] Fixed bug that caused duplicate diagnostics to be reported for quoted type annotations in some cases. --- server/src/analyzer/typeEvaluator.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/analyzer/typeEvaluator.ts b/server/src/analyzer/typeEvaluator.ts index a61eaac1c..dc569a6ba 100644 --- a/server/src/analyzer/typeEvaluator.ts +++ b/server/src/analyzer/typeEvaluator.ts @@ -702,6 +702,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags: checkForCancellation(); let typeResult: TypeResult | undefined; + let reportExpectingTypeErrors = (flags & EvaluatorFlags.ExpectingType) !== 0; switch (node.nodeType) { case ParseNodeType.Name: { @@ -769,6 +770,10 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags: ); typeResult = { node, type: UnknownType.create() }; } + + // Don't report expecting type errors again. We will have already + // reported them when analyzing the contents of the string. + reportExpectingTypeErrors = false; } else { // Evaluate the format string expressions in this context. node.strings.forEach((str) => { @@ -941,7 +946,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags: fail(`Unhandled expression type '${ParseTreeUtils.printExpression(node)}'`); } - if (flags & EvaluatorFlags.ExpectingType) { + if (reportExpectingTypeErrors) { const resultType = transformTypeObjectToClass(typeResult.type); if (!TypeBase.isInstantiable(resultType)) { const isEmptyTuple =