iqsharp icon indicating copy to clipboard operation
iqsharp copied to clipboard

In Python+Q# notebooks, error messages point to line numbers off-by-one

Open tcNickolas opened this issue 3 years ago • 3 comments
trafficstars

Describe the bug In Python+Q# notebooks (both local and hosted on Azure Quantum), error message points to the line number off-by-one due to %%qsharp magic command taking up the first line. (Same as https://github.com/microsoft/QuantumKatas/issues/658.)

To Reproduce Run any %%qsharp cell with a compilation error in it.

Expected behavior Displayed line numbers should match the ones where the error is.

tcNickolas avatar Sep 30 '22 05:09 tcNickolas

Thanks for pointing this out. At the moment, we don't have a mechanism to set the line offset based on how the code was passed. I agree it'd be worth adding, but it may take a little bit of work to plumb that through Jupyter executions so as to make sure that the final compilation has that context. We'll try to take a look at this, then. Thanks!

cgranade avatar Sep 30 '22 22:09 cgranade

Would a simple workaround like appending an empty string to the code in the %%qsharp magic command before it's passed on to compilation work?

tcNickolas avatar Sep 30 '22 22:09 tcNickolas

Ah, fair point— it may yeah... can look at that soon, then, hopefully.

cgranade avatar Sep 30 '22 22:09 cgranade