derive: make EvaluatedResult know its unknown result#538
Merged
GuillaumeGomez merged 1 commit intoaskama-rs:masterfrom Jul 23, 2025
Merged
derive: make EvaluatedResult know its unknown result#538GuillaumeGomez merged 1 commit intoaskama-rs:masterfrom
EvaluatedResult know its unknown result#538GuillaumeGomez merged 1 commit intoaskama-rs:masterfrom
Conversation
| // condition. | ||
| compare( | ||
| "{% if y == 3 || (true || x == 12) %}{{x}}{% endif %}", | ||
| r"if askama::helpers::as_bool(&(self.y == 3)) || (true) { |
Member
Author
There was a problem hiding this comment.
Expr::BinOp(v) if v.op == "||" => .. and Expr::BinOp(v) if v.op == "&&" => .. don't build a binary op anymore if the outcome of one leg is known. Except for expr && false, which keeps expr for its side effect.
Member
Author
There was a problem hiding this comment.
Ahh, that's wrong. Will fix.
Member
Author
There was a problem hiding this comment.
Expr::Group(_) now directly returns true or false if the result is known, instead of (true) or (false). That's why there is still a change in this line, but I fixed my previous mistake. :)
Collaborator
There was a problem hiding this comment.
Makes sense! That's an improvement. :)
34c73bd to
2da5760
Compare
This PR adds a `WithSpan<Expr>` member to `EvaluatedResult::Unknown`, so `Generator::evaluate_condition()` does not have to return a tuple.
2da5760 to
78c0ab9
Compare
GuillaumeGomez
approved these changes
Jul 23, 2025
Collaborator
|
This is much better, thanks! |
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.
This PR adds a
WithSpan<Expr>member toEvaluatedResult::Unknown, soGenerator::evaluate_condition()does not have to return a tuple.Resolves #535.
(Can a discussion be resolved? I guess I'll stick with issues again in the future.)