Skip to content

fix(frontend): ignore unreachable breaks in raw loop validation - #13344

Draft
AztecBot wants to merge 1 commit into
masterfrom
cb/noir-audit-remediation-1041-loop-break-reachability
Draft

fix(frontend): ignore unreachable breaks in raw loop validation#13344
AztecBot wants to merge 1 commit into
masterfrom
cb/noir-audit-remediation-1041-loop-break-reachability

Conversation

@AztecBot

Copy link
Copy Markdown
Collaborator

Summary

Raw loop validation now ignores break statements that are inside compile-time-dead literal if branches. This keeps the frontend's infinite-loop rejection aligned with the SSA lowering path that removes those dead branches before loop codegen.

Fix

  • Preserve loop-break accounting only for the reachable branch of literal if true / if false conditions.
  • Add regressions for if false { break; } and if true { continue; } else { break; } inside raw loops.

Testing

  • cargo test -p noirc_frontend loop_with_break -- --nocapture
  • cargo test -p noirc_frontend errors_if_loop_body_type_is_not_unit -- --nocapture
  • cargo fmt

Issues

  • Closes noir-lang/noir-claude#1041 — raw loop accepted statically unreachable breaks and could compile to an endless Brillig function

Created by claudebox · group: noir-audit-remediation

@TomAFrench
TomAFrench force-pushed the cb/noir-audit-remediation-1041-loop-break-reachability branch from 32e8b5e to f31af8a Compare July 29, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant