microsoft / qsharp

Azure Quantum Development Kit, including the Q# programming language, resource estimator, and Quantum Katas
https://microsoft.github.io/qsharp/
MIT License
369 stars 73 forks source link

RCA check reports error only on entry point rather than also on the line generating the required capability #1537

Closed swernli closed 1 month ago

swernli commented 1 month ago

With the following code, RCA produces the expected error message but only on the entry point rather than on the line that produced the dynamic string (playground):

namespace MyQuantumProgram {
    operation ApplyAndMeasure(op : Qubit => Unit, q : Qubit) : Bool {
        op(q);
        return MResetZ(q) == One;
    }

    @EntryPoint()
    operation Main() : Result[] {
        use q = Qubit();
        let b = ApplyAndMeasure(H, q);
        let s = b ? "One" | "Zero";

        return [];
    }
}

The is reported at Main() which is expected but missing from let s = b ? "One" | "Zero";