Skip to content

feat: split ControlInfo.noFallthrough from syntactic numRegularExits#13502

Merged
sgraf812 merged 1 commit into
masterfrom
sg/control-info-deadcode
Apr 22, 2026
Merged

feat: split ControlInfo.noFallthrough from syntactic numRegularExits#13502
sgraf812 merged 1 commit into
masterfrom
sg/control-info-deadcode

Conversation

@sgraf812
Copy link
Copy Markdown
Contributor

@sgraf812 sgraf812 commented Apr 22, 2026

This PR splits ControlInfo's dead-code signal in two. numRegularExits is now purely syntactic: how many times the block wires its continuation into the elaborated expression, consumed by withDuplicableCont as a join-point duplication trigger (> 1). The new noFallthrough : Bool asserts that the next doElem in the enclosing sequence is semantically irrelevant; false asserts nothing. Invariant: numRegularExits = 0 → noFallthrough; the converse does not hold. sequence derives noFallthrough := a.noFallthrough || b.noFallthrough (and aggregates syntactic fields unconditionally); alternative derives it as a.noFallthrough && b.noFallthrough. The dead-code warning gate in withDuplicableCont and ControlLifter.ofCont now reads noFallthrough.

@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Apr 22, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

mathlib-lean-pr-testing Bot commented Apr 22, 2026

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f32106283fab28c339b2e3a0d0a5f606fd3175ae --onto 10338ed1b00a9c3fb864ee80b02b311cd7c9e2c5. You can force Mathlib CI using the force-mathlib-ci label. (2026-04-22 08:14:25)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f32106283fab28c339b2e3a0d0a5f606fd3175ae --onto b6f5892e2247b3ca3c9a535e286f26121656d10f. You can force Mathlib CI using the force-mathlib-ci label. (2026-04-22 12:15:34)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase f32106283fab28c339b2e3a0d0a5f606fd3175ae --onto 3fc99eef102549c743c6c63547983319bfae6f01. You can force reference manual CI using the force-manual-ci label. (2026-04-22 08:14:27)

This PR splits `ControlInfo`'s dead-code signal in two.
`numRegularExits` is now purely syntactic: the number of times the
block wires its continuation into its elaborated expression, consumed
by `withDuplicableCont` as a join-point duplication trigger (`> 1`).
The new `noFallthrough : Bool` asserts that the next doElem in the
enclosing sequence is semantically irrelevant; `false` asserts
nothing. Invariant: `numRegularExits = 0 → noFallthrough`; the
converse does not hold. `sequence` derives `noFallthrough` as
`a.noFallthrough || b.noFallthrough` (and aggregates syntactic fields
unconditionally); `alternative` derives it as
`a.noFallthrough && b.noFallthrough`. The dead-code warning gate in
`withDuplicableCont` and `ControlLifter.ofCont` now reads
`noFallthrough`.
@sgraf812 sgraf812 force-pushed the sg/control-info-deadcode branch from 2828b31 to 767f84f Compare April 22, 2026 11:23
@sgraf812 sgraf812 changed the title feat: split ControlInfo.exitsDead from syntactic numRegularExits feat: split ControlInfo.noFallthrough from syntactic numRegularExits Apr 22, 2026
@sgraf812 sgraf812 added the changelog-language Language features and metaprograms label Apr 22, 2026
@sgraf812 sgraf812 added this pull request to the merge queue Apr 22, 2026
Merged via the queue into master with commit 2b99012 Apr 22, 2026
25 of 27 checks passed
@sgraf812 sgraf812 deleted the sg/control-info-deadcode branch April 22, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-language Language features and metaprograms toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants