`input` and `output` declarations are unusable
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 28/100
Línea de trabajo
Start with Qasm3Visitor._visit_classical_declaration in src/pyqasm/visitor.py, and check how the IODeclaration node from openqasm3 falls through without a scope entry. Reproduce the four failing snippets in the issue, then read tests/qasm3/test_declarations.py. Done means those snippets validate, output can be a measurement target, and dumps() keeps both qualifiers. The binding-versus-symbolic question must be settled by a maintainer before implementation.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Limitation
Input/output defines input and output
modifiers on classical declarations. input marks a value supplied at run time — the spec's
motivating case is a parameterised circuit compiled once and executed many times with
different angles. output marks a value returned to the host.
pyqasm parses both declarations but never registers them in scope. Any later use fails.
Example QASM failure
The spec's own parameterised-circuit pattern:
OPENQASM 3.0;
include "stdgates.inc";
input float[64] a;
qubit[1] q;
rx(a) q[0];
// ValidationError: Invalid parameter 'a' for gate 'rx'
An input used in ordinary classical code fails the same way:
OPENQASM 3.0;
input int[8] a;
int[8] b = a;
// ValidationError: Invalid initialization value for variable 'b'
output is not registered either:
OPENQASM 3.0;
output bit[2] c;
qubit[2] q;
c = measure q;
// ValidationError: Missing register declaration for 'c' in measurement operation
OPENQASM 3.0;
output int[8] c;
c = 1;
// ValidationError: Undefined variable c in assignment
A bare input bit[2] a; with no subsequent use validates cleanly, which confirms the
declaration is parsed and then discarded.
Change Requested
- Register
inputandoutputdeclarations in the global scope with their declared types,
so that every later reference resolves. - An
output-qualified variable must be assignable, including as a measurement target. - Preserve both qualifiers through
dumps()— a round-trip must not silently turn aninput
into an ordinary declaration. - Enforce the spec's scope rule:
inputandoutputare permitted only in global scope.
Open design question
pyqasm's unroller evaluates classical expressions to concrete values, but an input has no
value at analysis time. Two viable directions, and this issue should settle which:
- Binding API — accept values at load or unroll time, e.g.
pyqasm.loads(qasm, inputs={"a": 0.5}), and substitute them during unrolling. Concrete
output, no representation change, but requires the caller to supply every input. - Symbolic passthrough — treat an unbound
inputas an opaque symbol, validate its type
and usage, and emit the expression unevaluated. Keeps the program parameterised at the cost
of expression handling that tolerates non-numeric operands.
Supporting both — bind when a value is given, pass through when it is not — is likely the
right end state, but the first increment should pick one. Maintainer input needed.
Implementation Details
openqasm3exposes the qualifier asIOKeyword.input/IOKeyword.outputon
ClassicalDeclaration/IODeclaration. Confirm which node type the parser produces for
each so the visitor branches correctly.- The declaration path is
Qasm3Visitor._visit_classical_declarationin
src/pyqasm/visitor.py; theIODeclarationnode appears to fall through without a scope
entry. Registering the variable is the minimal fix that clears all four failures above. - The error
"Invalid parameter 'a' for gate 'rx'"comes from the gate-argument evaluation
path — it fires because the identifier does not resolve, so scope registration fixes it
directly under the binding approach, and requires expression-level tolerance under the
symbolic approach. outputneeds the variable marked assignable and visible to the measurement path that
raises"Missing register declaration for 'c' in measurement operation".- Tests:
tests/qasm3/test_declarations.py—inputin a gate argument,inputin classical
arithmetic,outputas a measurement target,outputin a plain assignment, adumps()
round-trip preserving both keywords, andinputdeclared inside adefbody raising a
ValidationError.
- Lenguaje dominante
- Python
- Estrellas
- 29
- Forks
- 33
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 15
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de qBraid/pyqasm
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
Los mantenedores suelen responder en 1 día
-
enhancement error-handling program-validation
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Move the QASM 2 printer and its branch pre-processing out of qasm2.pyPosiblemente ocupada @danielgaskins la tomó hace 7 días. Abiertoenhancement qasm2
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
qBraid/pyqasm#447 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG] dumps() emits extern calls without a semicolon, producing unparsable QASMPosiblemente ocupada @Jah-yee la tomó hace 15 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 25/100
qBraid/pyqasm#438 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lostPosiblemente ocupada @tonycoder-hub la tomó hace 9 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 22/100
qBraid/pyqasm#436 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de qBraid/pyqasm
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
anchore/grype-db#1149 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Bug]: `hermes plugins update` clones an entire monorepo twice - `subdir` is resolved but dropped at both catalog-update call sitesPosiblemente ocupada @HootRock la tomó hoy. Abiertocomp/cli P2 type/perf
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
NousResearch/hermes-agent#142417 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
SMC SPEC
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
tenstorrent/tt-oca-harness#3287 ·
Los mantenedores suelen responder en 1 día
-
bug enhancement python
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
DewaldOosthuizen/tech-cheat-sheets-and-notes#392 ·
Los mantenedores suelen responder en 1 día
-
Critical advisories on mainAbiertosecurity
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
fabriziosalmi/wildbox#801 ·
Los mantenedores suelen responder en 1 día