From 57b2c4730df03f5092a9ea369fab228ff4b0f64c Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Tue, 21 May 2024 22:13:30 -0700 Subject: [PATCH] Fix error type on circuit error (#1553) --- vscode/src/circuit.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/vscode/src/circuit.ts b/vscode/src/circuit.ts index b35a8ec24e..2ddf24ba47 100644 --- a/vscode/src/circuit.ts +++ b/vscode/src/circuit.ts @@ -10,7 +10,6 @@ import { IRange, ProgramConfig, TargetProfile, - VSDiagnostic, getCompilerWorker, log, } from "qsharp-lang"; @@ -268,7 +267,7 @@ async function getCircuitOrError( if (typeof e === "string") { try { errors = JSON.parse(e); - resultCompError = hasResultComparisonError(e); + resultCompError = hasResultComparisonError(errors); } catch (e) { // couldn't parse the error - would indicate a bug. // will get reported up the stack as a generic error @@ -284,13 +283,12 @@ async function getCircuitOrError( } } -function hasResultComparisonError(e: unknown) { - const errors: [string, VSDiagnostic, string][] = - typeof e === "string" ? JSON.parse(e) : undefined; +function hasResultComparisonError(errors: IQSharpError[]) { const hasResultComparisonError = errors && errors.findIndex( - ([, diag]) => diag.code === "Qsc.Eval.ResultComparisonUnsupported", + (item) => + item?.diagnostic?.code === "Qsc.Eval.ResultComparisonUnsupported", ) >= 0; return hasResultComparisonError; }