feat(rengine, lean): add rejection phase that ensures an expression is in the Lean do-notation DSL#1739
Merged
clementblaudeau merged 13 commits intomainfrom Oct 21, 2025
Merged
Conversation
9614a1f to
eccabf3
Compare
Add the [Phase(String)] context, to indicate an error in a phase Improve error message for [ExplicitRejection] errors
eccabf3 to
3e12ce9
Compare
d9e7ff1 to
1acf9a6
Compare
maximebuyse
approved these changes
Oct 15, 2025
Contributor
maximebuyse
left a comment
There was a problem hiding this comment.
I added some comments but this looks good!
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.
Context
The Lean backend produces code that targets Lean's do-notation, providing handy ways to chain monadic let-bindings. This notation actually defines a small internal DSL with do-expressions, do-statements and normal lean-expressions (as a fallback). This PR adds a (rust-engine) phase that rejects interleavings of expressions and statements that are outside this DSL. Eventually, it should be removed in favor of a phase that automatically hoist out let-bindings and control flow operators, in order to always stay inside the DSL (see #1741).
This PR also updates some error messages.
Examples
The following is rejected:
Other cases can be found in
tests/lean-tests/src/reject_do_dsl.rs