[BUG] dumps() emits extern calls without a semicolon, producing unparsable QASM
I maintainer di solito rispondono entro 1 giorno
@Jah-yee ci sta già lavorando.
Dal 5/10/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 25/100
Direzione di ricerca
The extern call is appended unwrapped in _handle_extern_function_cleanup in src/pyqasm/visitor.py (around line 591), so start there and check where the extern statement list is assembled. Reproduce with the snippet in the issue and inspect [type(s).__name__ for s in m.unrolled_ast.statements]. Done means the call is wrapped in qasm3_ast.ExpressionStatement and openqasm3.parse(pyqasm.dumps(m)) succeeds for the extern fixtures. Note that PR #450 is open against this issue and #446 was closed unmerged, so check with maintainers before starting.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Environment
- pyqasm version: 1.2.0 (
main@ 036ad4d) - Python version: 3.12
- Operating system: macOS 15
What happened?
dumps() emits an extern function call without its terminating semicolon, so the generated
program is not valid OpenQASM and will not reparse.
import openqasm3, pyqasm
m = pyqasm.loads("""OPENQASM 3.0;
extern my_extern(int);
my_extern(3);
""")
m.unroll()
out = pyqasm.dumps(m)
print(out)
openqasm3.parse(out)
OPENQASM 3.0;
extern my_extern(int);
my_extern(3)
openqasm3.parser.QASM3ParsingError
With any statement following the call, the two run together on one line:
qubit[1] q;
my_extern(3)x q[0]; # line 5:12 no viable alternative at input 'my_extern(3)'
The cause is the node type, not the printer. The unrolled AST holds a bare FunctionCall
where a statement belongs:
>>> [type(s).__name__ for s in m.unrolled_ast.statements]
['ExternDeclaration', 'FunctionCall']
FunctionCall is an expression node, so openqasm3.printer renders it as an expression —
no semicolon, no line break. It should be wrapped in an ExpressionStatement.
Scope is narrow: only extern calls are affected. Subroutine calls and builtin calls both
round-trip correctly.
extern call QASM3ParsingError tail: ['qubit[1] q;', 'my_extern(3)x q[0];']
extern, no follow QASM3ParsingError tail: ['qubit[1] q;', 'my_extern(3)']
subroutine call reparses OK tail: ['x q[0];', 'x q[0];']
builtin call reparses OK tail: ['qubit[1] q;', 'x q[0];']
Suggestions (Optional)
Wrap the call in qasm3_ast.ExpressionStatement before it is appended to the output
statements — _handle_extern_function_cleanup (src/pyqasm/visitor.py:591) is where the
extern statement list is assembled.
Worth a round-trip assertion in the tests either way: openqasm3.parse(pyqasm.dumps(m)) over
the existing extern fixtures would have caught this, and would catch the same class of bug for
any other node that reaches the statement list unwrapped.
Found while reviewing #425, which touches the expression-statement path but does not cause or
fix this — it reproduces identically on main.
- Lingua principale
- Python
- Stelle
- 29
- Fork
- 33
- Merge medio
- 2g 4h
- PR unite (30g)
- 15
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di qBraid/pyqasm
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement error-handling program-validation
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Move the QASM 2 printer and its branch pre-processing out of qasm2.pyForse già presa @danielgaskins l’ha presa 7 giorni fa. Apertaenhancement qasm2
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
qBraid/pyqasm#447 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lostForse già presa @tonycoder-hub l’ha presa 9 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 22/100
qBraid/pyqasm#436 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
`extern port` / `extern frame` in `cal` blocks fail to parse, blocking nearly every spec OpenPulse exampleForse già presa @Riiocodee l’ha presa 1 giorno fa. Apertabug llm-assisted qasm3 qasm3-coverage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
qBraid/pyqasm#401 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di qBraid/pyqasm
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ansys/pyansys-common-mcp#213 ·
I maintainer di solito rispondono entro 3 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
freedomofpress/dangerzone#1594 ·
I maintainer di solito rispondono entro 3 giorni
-
priority:P1 status:in-review type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
randomparity/kdive#3317 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
area:ci
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
mesonbuild/meson#16281 ·
I maintainer di solito rispondono entro 1 giorno