Repository navigation
fix(expression): treat constants as neutral in IsBoundVisitor - #1004
Merged
Merged
Conversation
AlwaysTrue/AlwaysFalse no longer make IsBoundVisitor fail. Constants contain no references and are now neutral when combining binding states, so And(True, unbound) is unbound and And(True, bound) is bound. Mixing bound and unbound predicates is rejected with an error. This follows Java's IsBoundVisitor.
wgtmac
approved these changes
Oct 13, 2026
Member
|
Thanks for separating a smaller PR! @YinZheng-Sun |
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.
What
IsBoundVisitorpreviously returned an error forAlwaysTrue/AlwaysFalse,so any expression tree that still contained a constant (e.g. built via
And::Make/Or::Makewithout folding) could not be checked.This PR changes the visitor's internal result type to
std::optional<bool>:std::nulloptmeans the subtree contains no references (True/False),so constants are neutral when combining binding states:
And(True, unbound)is unbound andAnd(True, bound)is bound.Found partially bound expressioninstead of silently returningfalse.IsBoundVisitor::IsBound()API still returns a definitebool(an expression with only constants is reported as not bound).
This follows Java's
IsBoundVisitor.Why
Split out from #956
Tests
IsBoundVisitorTestfor constants and mixed binding states.AndWithConstants/OrWithConstantscases.