Skip to content

Broadcasting and slicing updates #2326

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

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

Conversation

orpuente-MS
Copy link
Contributor

@orpuente-MS orpuente-MS commented Apr 22, 2025

This PR completes some postponed items from #2149:

  • Gate call broadcasting.
  • Multidimensional array indexing.
  • Array slicing.
  • Fixes issue with assign ops being compiled incorrectly.

@idavis idavis changed the title Qasm parser follow up Broadcasting and slicing updates Apr 22, 2025
for index in &index_expr.indices {
let index = self.compile_index(index);
let span = Span {
lo: index_expr.span.lo,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lo span doesn't feel correct

Copy link
Contributor Author

@orpuente-MS orpuente-MS Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no right answer here since the source syntax is different from Q#'s syntax.

The idea is that this source code

a[1, 2, 3, 4]

will get compiled to

a[1][2][3][4]

The span in your comment is the span of the expression being indexed. For example, if we are currently building a[1][2][3], the expression being indexed is a[1][2]. But in the source code this corresponds to a[1, 2, and that's what I'm setting the span to, which doesn't feel as intuitive as in Q#, but it's a best effort solution. Let me know if you can think of something better.

@orpuente-MS orpuente-MS marked this pull request as ready for review April 24, 2025 21:23
@idavis idavis marked this pull request as draft April 29, 2025 18:07
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.

2 participants