When Q# program fails in "Run" or "Debug" mode, circuit panel shows gibberish error
Have the following code in a .qs file:
namespace MyQuantumApp {
@EntryPoint()
operation Main() : Unit {
use q = Qubit();
if (M(q) == Zero) {
fail "hi"
}
}
}
In VS Code, click the "circuit" code lens. This shows that we ran in trace mode, and shows the appropriate failure message. This is good.
Now, while the Q# circuit diagram is up click the "run" code lens. This will show a failure from the WASM layer instead.
Expected behavior: These two screenshots should show the same error.
error stack
Error: runtime error
at imports.wbg.__wbindgen_error_new (http://localhost:3000/static/devextensions/out/debugger/debug-service-worker.js:1118:17)
at wasm_bindgen::JsError::new::hd3f7701b29244ddd (wasm://wasm/0434b0ee:wasm-function[22149]:0xba7fd0)
at <wasm_bindgen::JsError as core::convert::From<E>>::from::hbf7538ad26697b82 (wasm://wasm/0434b0ee:wasm-function[17369]:0xb09030)
at qsc_wasm::debug_service::DebugService::eval::hed926055a67a214d (wasm://wasm/0434b0ee:wasm-function[3235]:0x657315)
at qsc_wasm::debug_service::DebugService::eval_continue::h0f60c85eada2d2ac (wasm://wasm/0434b0ee:wasm-function[20118]:0xb6d54f)
at debugservice_eval_continue (wasm://wasm/0434b0ee:wasm-function[5983]:0x7fc5b2)
at DebugService.eval_continue (http://localhost:3000/static/devextensions/out/debugger/debug-service-worker.js:703:12)
at QSharpDebugService.evalContinue (http://localhost:3000/static/devextensions/out/debugger/debug-service-worker.js:1942:30)
at invokeMethod (http://localhost:3000/static/devextensions/out/debugger/debug-service-worker.js:1782:30)
at messageHandler2 (http://localhost:3000/static/devextensions/out/debugger/debug-service-worker.js:1855:11)
The issue seems to be that the errors coming from the debugger (see below)...
https://github.com/microsoft/qsharp/blob/eb4b81bfb7ba62da3076197656d6dac181b760a9/vscode/src/debugger/session.ts#L399 https://github.com/microsoft/qsharp/blob/eb4b81bfb7ba62da3076197656d6dac181b760a9/vscode/src/debugger/session.ts#L320
don't match the errors coming from the circuit generator, which undergo a lot of "massaging" to look nice (see below)...
https://github.com/microsoft/qsharp/blob/eb4b81bfb7ba62da3076197656d6dac181b760a9/vscode/src/circuit.ts#L252
yet we pass all these errors to updateCircuitPanel in the exact same way.