Skip to content

Slicing on classical registers #250

@vmartinv

Description

@vmartinv

I'm trying to write code in QASM 3 and this is the only compiler I found. I'm having problems with slicing classical registers as shown below:

OPENQASM 3;

bit c[8]="01010101";
print(c[0:4]);

gives me:

bash-5.1$ qcor -qpu aer -shots 1  test.qasm -o test

[OPENQASM3 MLIRGen] cannot parse the source.
error: no viable alternative at input 'print(c[0:'
occurred at test:3:9, offending symbol = :

[qcor-exec] fatal error.

Am I doing something wrong?

Using let it seems that it somehow thinks is a qubit array:

OPENQASM 3;

bit c[8]="01010101";
let slice = c[0:4];
print(slice);

gives me:

bash-5.1$ qcor -qpu aer -shots 1  test.qasm -o test

[OPENQASM3 MLIRGen] Error
Could not infer qubit[] size from block argument. No size attribute for variable in symbol table.

[qcor-exec] fatal error.

I don't know if I'm making something wrong or if there's an error in qcor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions