Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set type of measurement expression correctly #52

Merged
merged 2 commits into from
Jan 19, 2024
Merged

Conversation

jlapeyre
Copy link
Collaborator

@jlapeyre jlapeyre commented Jan 19, 2024

This PR does two things

  • Set the type of a measurement (In TExpr with variant MeasurementExpression) correctly.
    That is measuring a qubit or hardware qubit results in a bit. Measuring a qubit register results in a bit register of the same length.
  • Log semantic errors IncompatibleTypeError if the argument to measure is of invalid type.

See #42 (comment)

A type error in a typed expression (TExpr) is represented by a variant such as Type::Unknown. An alternative would be to let the type be a Result. In any case, in this PR, to continue with the current implementation, we choose Type::Unknown if the operand to measure is not a valid quantum type.

Closes #51

That is measuring a qubit or hardware qubit results in a bit.
Measuring a qubit register results in a bit register of the same length.

Closes #51
Log semantic error for incorrectly typed args to `measure`.
@jlapeyre jlapeyre merged commit 3e99dd0 into main Jan 19, 2024
3 checks passed
@jlapeyre jlapeyre deleted the gate-operand-type branch January 23, 2024 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Correctly type GateOperand
1 participant