Conversation
The convergence loop exits when either prev_repr == this_repr (success) or steps >= CONSTANT_GENERATIONS_ALLOWED (failure). The post-loop check if steps == CONSTANT_GENERATIONS_ALLOWED cannot distinguish those two cases when convergence actually happens on the very last allowed iteration, and will incorrectly raise "Constant generation didn't converge in allowed iteration limit" for a program that did in fact converge. Changes Made Made the limit configurable (src/compiler/comptypes.rs, src/compiler/compiler.rs): Added constant_generation_limit() / set_constant_generation_limit() to CompilerOpts, DefaultCompilerOpts, and the delegation trait. This allows tests to exercise the boundary condition with small limits. Wrote a regression test (src/tests/compiler/modules.rs): test_convergence_loop_boundary_does_not_false_positive sets the limit to 1 and compiles a module that converges in one iteration, directly triggering the false-positive error. Fixed the check (src/compiler/codegen.rs): Changed from if steps == generation_limit to if prev_repr != this_repr, which directly tests whether convergence actually happened regardless of step count.
…' into fix-convergence-test
Contributor
Author
|
We will make a smaller, more focused PR |
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.
The convergence loop exits when either prev_repr == this_repr (success) or steps >= CONSTANT_GENERATIONS_ALLOWED (failure). The post-loop check if steps == CONSTANT_GENERATIONS_ALLOWED cannot distinguish those two cases when convergence actually happens on the very last allowed iteration, and will incorrectly raise "Constant generation didn't converge in allowed iteration limit" for a program that did in fact converge.
Changes Made
Made the limit configurable (src/compiler/comptypes.rs, src/compiler/compiler.rs): Added constant_generation_limit() / set_constant_generation_limit() to CompilerOpts, DefaultCompilerOpts, and the delegation trait. This allows tests to exercise the boundary condition with small limits.
Wrote a regression test (src/tests/compiler/modules.rs): test_convergence_loop_boundary_does_not_false_positive sets the limit to 1 and compiles a module that converges in one iteration, directly triggering the false-positive error.
Fixed the check (src/compiler/codegen.rs): Changed from if steps == generation_limit to if prev_repr != this_repr, which directly tests whether convergence actually happened regardless of step count.
Note
Medium Risk
Touches the module constant-generation convergence loop and compiler option plumbing; while the behavioral change is small, it affects core codegen termination/error conditions for module compilation.
Overview
Fixes a boundary-condition in the module constant-generation convergence loop so compilation no longer errors when convergence happens on the last allowed iteration (post-loop check now verifies
prev_repr != this_reprrather than relying on the step counter).Makes the convergence iteration limit configurable via
CompilerOpts(constant_generation_limit+ setter), wires it throughDefaultCompilerOpts, and adds a regression test that sets the limit to1to exercise the failing edge case.Reviewed by Cursor Bugbot for commit 8e62882. Bugbot is set up for automated code reviews on this repo. Configure here.