Skip to content

Commit

Permalink
Fix error type on circuit error (#1553)
Browse files Browse the repository at this point in the history
  • Loading branch information
billti authored May 22, 2024
1 parent a7ce77a commit 57b2c47
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions vscode/src/circuit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
IRange,
ProgramConfig,
TargetProfile,
VSDiagnostic,
getCompilerWorker,
log,
} from "qsharp-lang";
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand Down

0 comments on commit 57b2c47

Please sign in to comment.