Skip to content

Program.to_ast mutates program. #4

@PhilReinhold

Description

@PhilReinhold

Currently

p1 = Program()
...
p2 = Program()
...
p1.to_qasm()
(p1 + p2).to_qasm()

and

p1 = Program()
...
p2 = Program()
...
# skip this --> p1.to_qasm() 
(p1 + p2).to_qasm()

Produce different outcomes because the autodeclaration in to_ast mutates p1. One potential solution is to (at least by default) copy the program before converting to ast, although this could have performance concerns. A faster solution could be to change the autodeclaration code such that it only affected the generated output, rather than the state of the program.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions