fix: walk loop and switch bodies in module statement passes - #360
fix: walk loop and switch bodies in module statement passes#360ryanhill1 wants to merge 2 commits into
Conversation
has_measurements(), remove_measurements(), has_barriers() and remove_barriers() fall back to _statements when the module has not been unrolled, and that list can still hold for/while/switch bodies the walker did not descend into — so an occurrence inside a loop or switch was invisible and removal was a no-op. iter_quantum_statements and drop_statements now descend into loop blocks and switch cases. Fixes #354
Argus reviewAuto-review is off for this repo. Tick the box below to run a review on this PR.
Estimated cost
Tip: you can also comment |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@Argus-Eye review |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🔎 Argus · 10/10 — Correctly extends statement passes into loop and switch bodies
🔍 PR intent vs diff (LLM analysis)
Argus read the diff against the stated intent. This is not an execution log — reviewer still needs to test behavior.
Goal: Make module statement passes detect and remove measurements and barriers inside for, while, and switch bodies before unrolling.
Not in scope:
- The unrolled path is unchanged; loops and switches are fully expanded by unroll() and do not reach _unrolled_ast with their bodies intact.
Stated acceptance criteria (from PR/issue — not independently verified): - iter_quantum_statements descends into for and while loop blocks and switch cases/default.
- drop_statements descends into for and while loop blocks and switch cases/default.
- has_measurements(), remove_measurements(), has_barriers(), and remove_barriers() handle occurrences inside non-unrolled loop and switch bodies.
✅ Intent delivered
Verdict: This PR adds the intended traversal and removal support for measurements and barriers in non-unrolled loop and switch bodies. It is ready to merge.
💡 2 P2 · 4 files reviewed
Architecture: The recursive traversal keeps module-level statement passes consistent with nested AST structure; broader nested-control-flow coverage would further protect this behavior.
2 findings · 2 inline · 0 folded
🔢 118.9k tokens · $0.2737 total
| Stage | Tokens | Cost |
|---|---|---|
| Intent | 2.6k | $0.0000 |
| Triage | 2.8k | $0.0000 |
| Lead agent | 1.5k | $0.0000 |
| Review · bug_hunter | 20.9k | $0.0674 |
| Review · security | 21.0k | $0.0665 |
| Review · architecture | 20.8k | $0.0707 |
| Review · regression | 21.1k | $0.0692 |
| Review | 24.9k | $0.0000 |
| Acceptance | 1.2k | $0.0000 |
| Scoring | 1.0k | $0.0000 |
| Synthesis | 932 | $0.0000 |
Contract: production/full · checked: bug_hunter, security, architecture, regression · review took 1m32s
Dashboard → · React 👎 to dismiss · Reply to any inline comment or use @argus-eye help to chat
- while-loop measurement removal now asserted, not just detection - barrier removal test asserts the loop's gates survive the pass
Fixes #354
has_measurements()/remove_measurements()/has_barriers()/remove_barriers()fall back toself._statementswhen the module has not been unrolled, and the statement walker did not descend intofor/while/switchbodies — so an occurrence inside one was invisible and removal was a no-op.iter_quantum_statementsanddrop_statements(the walker #345 introduced forbox/if) now descend into loop blocks and switch cases/default. The unrolled path is unchanged: loops and switches are fully expanded byunroll()and never reach_unrolled_ast.Also in this PR:
Nested Statement Removal Flow
Auto-enriched by Argus