Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

🐛 Register-reference validation is incomplete in the parser

Aperta
#468 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
66/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
compilers

Direzione di ricerca

Inizia tracciando preprocessCode e i punti di ingresso menzionati validateTargets, parseBitRegisterRef e parseClassicConditionExpression, usando definedRegisters per comprendere i controlli esistenti sui qubit. Aggiungi la validazione dell’identificatore, dell’esistenza del registro, dei limiti dell’indice e dell’intervallo di expectedValue per entrambi i percorsi rilevanti. Il lavoro è completato quando i riferimenti malformati e i confronti impossibili vengono rifiutati, mentre i casi elencati come fuori ambito rimangono invariati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

🤖 AI text below 🤖

Problem statement

The parser has three related gaps in how it validates register references and comparison values:

  1. Well-formed identifier checking. Neither validateTargets (for qubit targets in gate calls) nor parseBitRegisterRef (for classical bits in if conditions) rejects malformed register names on lexical grounds. Inputs like c2] (dangling ]) or @# (not an identifier at all) slip through the shape check. On the qubit side the eventual definedRegisters lookup 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.

  2. Classical bit reference against declared registers. validateTargets verifies that qubit targets exist in definedRegisters and that the bit index fits within the register size. Nothing analogous runs for the register mentioned in an if condition: if (nonexistent == 1) and if (c[999] == 1) (with creg c[3]) both parse without complaint.

  3. expectedValue within the register's representable range. if (c == 999) on creg 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 isValidIdentifier helper (letter or underscore followed by letters, digits, or underscores). Use it in validateTargets (before the definedRegisters lookup) and in parseBitRegisterRef (before returning the reference).
  • Extend preprocessCode so it also runs an existence + bounds check on the register mentioned in the condition of an if, using the same definedRegisters map already available there. The exact placement (inside parseClassicConditionExpression or a separate validateClassicCondition pass) is an implementation detail.
  • Reject expectedValue values 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).
Lingua principale
C++
Stelle
21
Fork
8
Merge medio
5h 17m
PR unite (30g)
21

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di munich-quantum-toolkit/debugger

Tutte le issue di munich-quantum-toolkit/debugger

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.