Repository navigation
Conversation
godofecht
added a commit
that referenced
this pull request
Oct 7, 2026
…s shadowed (#729) Adds array_bounds_kept (for i in 0 to 4 over array<i32, 3>) and array_bounds_rebound (the body shadows i). The rebased commit also applies the #1414 rebinding rule to the new literal-bound path: the proof is dropped when the body assigns, shadows or addresses the induction name or the indexed array.
3 of 5 tasks
godofecht
added a commit
that referenced
this pull request
Oct 7, 2026
…s shadowed (#729) Adds array_bounds_kept (for i in 0 to 4 over array<i32, 3>) and array_bounds_rebound (the body shadows i). The rebased commit also applies the #1414 rebinding rule to the new literal-bound path: the proof is dropped when the body assigns, shadows or addresses the induction name or the indexed array.
godofecht
added a commit
that referenced
this pull request
Oct 7, 2026
…s shadowed (#729) Adds array_bounds_kept (for i in 0 to 4 over array<i32, 3>) and array_bounds_rebound (the body shadows i). The rebased commit also applies the #1414 rebinding rule to the new literal-bound path: the proof is dropped when the body assigns, shadows or addresses the induction name or the indexed array.
godofecht
force-pushed
the
fix/729-span-proof-invalidated-by-rebinding
branch
from
October 7, 2026 11:35
2a86145 to
7b543f4
Compare
godofecht
marked this pull request as ready for review
October 7, 2026 11:35
godofecht
added a commit
that referenced
this pull request
Oct 7, 2026
A literal-bound ascending loop `for i in 0 to N` with N <= M proves its indexed reads of `array<T, M>` in range, so FLOWC_CHECKS elides those checks. The proof is dropped when the loop body assigns, shadows or takes the address of the induction name or the indexed array (the #1414 rule). Goldens: array_bounds_elision, array_bounds_kept, array_bounds_rebound. Part of #729.
Contributor
Author
|
Note from the merge train: #1383 (literal-bound array bounds elision, merged as f43efb7) already applies the rebinding rule to its new |
This was referenced Oct 7, 2026
Contributor
Author
This was referenced Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #729. Does not close it.
Change
For
for i in 0 to xs.len, the C backend drops the bounds check onxs[i].flowc_cgen_bounds_span_baseaccepted the loop from its header alone, so a body that reassignedxs(or reboundi) still lost the check, andxs[i]could read past the new span. The length-hoisting path already guarded against this withflowc_cgen_name_rebound_in_node; the bounds path did not.flowc_cgen_bounds_span_basenow returnsAST_NONEwhen the body assigns, shadows or takes the address of the span or the induction variable, so the checks stay.flowc_cgen_name_rebound_in_nodereturns early for any id outside0 .. arena.len, so a negative sentinel field is never indexed.docs/language/spans.mdsays when range loops keep their checks.Evidence
Rebased onto main 9f1d6d0. Bootstrap regenerated in its own commit.
tests/cgen/span_bounds_rebinding.flowrequires thespan index out of boundsfault path. With main's compiler it fails (missing: flow_fault_handler("span index out of bounds")); with this branch it passes.span_bounds_elisionandspan_bounds_retainedstill pass, so the ordinary loop keeps its elision.flowc: PASS../compiler/scripts/bootstrap_from_c.sh --regen: fixed point at gen2.--verify: PASS../flow tool compiler/scripts/self_host_full.flow: ALL PASS.roundtrip.flow: ALL PASS../flow tool tests/cgen/run.flow: 128 passed, 0 failed../flow test-lang: 274/0../flow test-runtime: 34/0../flow tool tests/cli/run.flow: 152 passed, 2 failed (jit_hello,test_mlir: golden drift on main).Merge note: #1383 (also #729) touches other functions in
cgen.flowand merges cleanly apart from the generated bootstrap files. Whichever lands second needs its own bootstrap regeneration.