Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Incorrect compilation of within/apply block when code contains @EntryPoint() #266

@rmshaffer

Description

@rmshaffer

Describe the bug
When the code in a notebook contains @EntryPoint(), the adjoint of any within block is not applied.

(Thanks to @cgranade for finding and reporting this issue.)

To Reproduce
Steps to reproduce the behavior:

  1. Execute the following code in a Q# notebook cell:

    operation HXH() : Unit {
        using (q = Qubit()) {
            within { H(q); }
            apply { X(q); }
        }
    }
    
    @EntryPoint()
    operation DoNothing() : Unit {}
    
  2. Run %simulate HXH.

  3. This fails with the error: Released qubits are not in zero state. Inspection of the generated C# code reveals that the final H operation is not being applied.

Expected behavior
Operation should run successfully, since if compiled correctly, the qubits would be in the zero state when released.

Note that if the @EntryPoint() line is removed, everything works fine.

Screenshots
If applicable, add screenshots to help explain your problem.
image

System information

  • OS: Windows
  • Browser: Edge
  • Version: Latest master (as of 2020-08-13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-KernelIssue relates to the IQ# kernel.Kind-BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions