Skip to content

✨ Add support for register slices in the OpenQASM frontend #2110

Description

@denialhaag

πŸ€– AI text below πŸ€–

The OpenQASM frontend accepts only a single index in a subscript. Any range is rejected at the ::

h q[0:2];   // error: expected ']', got ':'

parseDesignator parses [, then one expression, then expects ], so this affects every subscript position, including gate operands, measure, and declarations. Constant and dynamic bounds fail alike, and the optional step form q[a:b:c] fails too.

Slices are needed for gates that act on part of a register, for example the multi-controlled ctrl(n-1) @ z q[0:n-2], flag in Grover's algorithm.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    MLIRAnything related to MLIRfeatureNew feature or request

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions