Skip to content

Handle conflicts between user-defined parameter names and automatically-modified parameter names #30

@rmshaffer

Description

@rmshaffer

Describe the bug
If a user labels subroutine parameters in a program as both xyz and xyz_, where xyz is some reserved word (like qubit or bit), this may lead to unexpected behavior, as the xyz gets automatically renamed to xyz_ during the transpilation process.

See this comment thread for more details: https://github.com/amazon-braket/autoqasm/pull/28/files#r1635398668

To reproduce
Create an aq.subroutine with parameters named qubit and qubit_. Note that AutoQASM tries to generate a subroutine with two parameters named qubit_, which causes an error.

Expected behavior
If the Python variable names are different, then we should ensure that the resulting OpenQASM variable names do not conflict.

We could also potentially add a comment (using /* */) in the generated OpenQASM when a variable name is modified, to be super clear to the user about how we have changed the program.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions