iqsharp icon indicating copy to clipboard operation
iqsharp copied to clipboard

Unhelpful error message on invalid return type

Open anjbur opened this issue 4 years ago • 0 comments

Describe the bug Unit return type is not allowed on provider submission. If this return type is used, a specific warning is given via dotnet compilation: warning QS6205: Only values of type Result, Result[], and tuples thereof can be returned when executing on a quantum processor. In IQ#, the error message given is:

image

To Reproduce Steps to reproduce the behavior:

  1. Create a new Q# notebook.
  2. Define an operation with return type Unit. Example:
open Microsoft.Quantum.Measurement;

operation PrepareBellPair(left : Qubit, right : Qubit) : Unit is Adj + Ctl {
    H(left);
    CNOT(left, right);
}

operation Teleport(msg : Qubit, target : Qubit) : Unit {
    use register = Qubit();

    PrepareBellPair(register, target);
    Adjoint PrepareBellPair(msg, register);

    if MResetZ(msg) == One      { Z(target); }
    if MResetZ(register) == One { X(target); }
}

operation RunTeleport() : Unit {
    use left = Qubit();
    use right = Qubit();

    H(left);
    Teleport(left, right);
    H(right);
}
  1. Connect to an Azure Quantum workspace and submit the job. image

Expected behavior A more helpful error message, like what is provided in dotnet compilation.

System information

  • OS: Windows 10
  • Browser: Edge
  • Version: 0.18.2107153439

anjbur avatar Jul 26 '21 22:07 anjbur