microsoft / qsharp-runtime

Runtime components for Q#
https://docs.microsoft.com/quantum
MIT License
286 stars 93 forks source link

Error message when operation with intrinsic body not implemented should be more helpful #466

Open tcNickolas opened 3 years ago

tcNickolas commented 3 years ago

Describe the bug

If runtime encounters an operation that has intrinsic body on a simulator that doesn't implement this body, it fails in a manner that doesn't point to the cause of failure.

To Reproduce

We noticed this when trying to run task 2.1 from PhaseEstimation kata on QuantumSimulator instead of CounterSimulator in this pull request (in VS/VS Code/dotnet test). It calls operation ResetOracleCallsCount that is not implemented the first thing in the test, so just running the test T21_SingleBitPE exposes the error message.

Expected behavior

It would be really helpful to have an error message pointing to the fact that an operation is used that does not have a body implemented.

Actual behavior

The actual error message is

[xUnit.net 00:00:01.7547204]     Quantum.Kata.PhaseEstimation.T21_SingleBitPE+QuantumSimulator.T21_SingleBitPE [FAIL]
  X Quantum.Kata.PhaseEstimation.T21_SingleBitPE+QuantumSimulator.T21_SingleBitPE [15ms]
  Error Message:
   Q# Test failed. For details see the Standard output below.
Expected: True
Actual:   False
  Stack Trace:
     at Quantum.Kata.PhaseEstimation.T21_SingleBitPE.QuantumSimulator.T21_SingleBitPE() in D:\github\QuantumKatas\PhaseEstimation\Tests.qs:line 104

(there is nothing in the standard output, and the line indicated in the error message points to the test itself, not to the operation that is not implemented)

System information

bettinaheim commented 3 years ago

I am not sure if this may need additional work on iqsharp. With the simulator changes this should become a proper linking failure (opposed to a runtime failure). We can take a look at how the message looks like after these changes are in, so I'll keep it here for now.