🐛 Register-reference validation is incomplete in the parser
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
- 66/100
Línea de trabajo
Comienza siguiendo preprocessCode y los puntos de entrada mencionados validateTargets, parseBitRegisterRef y parseClassicConditionExpression, usando definedRegisters para entender las comprobaciones de qubits existentes. Añade validación del identificador, de la existencia del registro, de los límites del índice y del rango de expectedValue para ambas rutas relevantes. Se considerará terminado cuando se rechacen las referencias malformadas y las comparaciones imposibles, mientras que los casos indicados fuera de alcance permanezcan sin cambios.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
🤖 AI text below 🤖
Problem statement
The parser has three related gaps in how it validates register references and comparison values:
-
Well-formed identifier checking. Neither
validateTargets(for qubit targets in gate calls) norparseBitRegisterRef(for classical bits inifconditions) rejects malformed register names on lexical grounds. Inputs likec2](dangling]) or@#(not an identifier at all) slip through the shape check. On the qubit side the eventualdefinedRegisterslookup rejects them indirectly with an "unknown register" error; on the classical side there is no lookup, so the error surfaces even later in the DD backend. -
Classical bit reference against declared registers.
validateTargetsverifies that qubit targets exist indefinedRegistersand that the bit index fits within the register size. Nothing analogous runs for the register mentioned in anifcondition:if (nonexistent == 1)andif (c[999] == 1)(withcreg c[3]) both parse without complaint. -
expectedValuewithin the register's representable range.if (c == 999)oncreg c[3](3 bits, values 0 to 7) is impossible to satisfy but the parser accepts it. The comparison always evaluates to false at runtime.
Surfaced during the review of PR #463.
Proposed solution
Add the three missing checks and share them where the same code path applies to qubits and classical bits:
- Extract a small
isValidIdentifierhelper (letter or underscore followed by letters, digits, or underscores). Use it invalidateTargets(before thedefinedRegisterslookup) and inparseBitRegisterRef(before returning the reference). - Extend
preprocessCodeso it also runs an existence + bounds check on the register mentioned in the condition of anif, using the samedefinedRegistersmap already available there. The exact placement (insideparseClassicConditionExpressionor a separatevalidateClassicConditionpass) is an implementation detail. - Reject
expectedValuevalues that exceed what the referenced register can hold (whole register or single bit).
Out of scope
- Reserved-word checking (
qreg,creg,measure, etc.). Separate semantic concern. - Compound expressions in the condition (out of scope of the parser as a whole today).
- Lenguaje dominante
- C++
- Estrellas
- 21
- Forks
- 8
- Merge medio
- 5 h 17 min
- PR fusionados (30 d)
- 21
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 munich-quantum-toolkit/debugger
-
Dificultad 3/5 1-2 días Aptitud para principiantes 84/100
munich-quantum-toolkit/debugger#469 ·
Los mantenedores suelen responder en 1 día
-
✨ Improve CLI UX: line editing, function-key shortcuts, and help barPosiblemente ocupada @rturrado la tomó hace 30 días. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
munich-quantum-toolkit/debugger#467 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
munich-quantum-toolkit/debugger#465 ·
Los mantenedores suelen responder en 1 día
-
c++ enhancement help wanted
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
munich-quantum-toolkit/debugger#168 ·
Los mantenedores suelen responder en 1 día
-
Dependency DashboardAbiertodependencies
Dificultad 5/5 Más de una semana Aptitud para principiantes 10/100
munich-quantum-toolkit/debugger#55 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de munich-quantum-toolkit/debugger
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
FriendsofECCE/ECCE#336 · 1 comentario ·
-
Real literal with a 'd' exponent and a kind suffix (1.0d0_4) is accepted; the suffix is ignoredAbiertoerror not reported low priority semantics
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
bitcoin-core/gui-qml#1030 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día