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

Generic functions break arrays #629

Open
mark-koch opened this issue Nov 7, 2024 · 0 comments
Open

Generic functions break arrays #629

mark-koch opened this issue Nov 7, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@mark-koch
Copy link
Collaborator

The Guppy type array[qubit, 42] is lowered to the Hugr type Array<Option<Qubit>> to allow non-linear indexing. The same also happens for array[T, 42] where T is a generic linear type variable.

However, when we subsitute T with a classical type (say int), it suddenly lowers to the Hugr type Array<Int<6>> without the Option! This results in ill-typed Hugrs whenever we invoke a generic array function with a classical type.

Short-term fix: Also use Option for classical values (but omitting the "replacing with None" logic). This is not very nice, but should solve the problem until we implement the proper solution.

Longer-term: Add a new Hugr extension for Guppy arrays that is lowered to regular arrays later on in the stack (after monomorphisation!). See #628.

@mark-koch mark-koch added the bug Something isn't working label Nov 7, 2024
@mark-koch mark-koch self-assigned this Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant