Repository navigation
Improve expression filter stack depth limits, plus fix a precedence bug - #2188
Open
jkbonfield wants to merge 5 commits into
Open
jkbonfield wants to merge 5 commits into
jkbonfield wants to merge 5 commits into
Conversation
jkbonfield
force-pushed
the
expr_depth
branch
2 times, most recently
from
November 30, 2026 11:29
2121c2a to
c0840aa
Compare
Note however there are also some grammar issues when it comes to computation within a single level of precedence. Eg 1<=2>1 is computed as 1<=(2>1) which is at odds with bc -l which does (1<=2)>1. <= and > are the same precedence, so it should be strictly left to right. Signed-off-by: James Bonfield <jkb@sanger.ac.uk>
This should fail until the next commit. Signed-off-by: James Bonfield <jkb@sanger.ac.uk>
Usually with expression operators that are grouped into the same precedence level we process them with a loop (either "for (;;)" or "while (*str)", so we explicitly combine in left to right order. However cmp_expr and eq_expr didn't do this. Instead they implemented the next level down combined with the a self loop. Eg 3>2 in cmp_expr was bitor_expr (3) > cmp_expr(2). That however means 3>2>1 becomes 3>(2>1) which is right to left instead of left to right, yielding the wrong answer. Signed-off-by: James Bonfield <jkb@sanger.ac.uk>
In testing, Claude suggested a far more concise way of coding this which is a lot less tedious to read through. This commit is a mixture of Claude's rewrite and my rephrasing of it. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: James Bonfield <jkb@sanger.ac.uk>
The expression "abc" == ("abc" < "b") should return 0 as it's
comparing a string ("abc") against a number (the boolean result of
"abc" < "b"). However the distinction was done on val.s.s and not on
val.is_str, which is this case is wrong as val.s.s is still "abc".
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: James Bonfield <jkb@sanger.ac.uk>
jkbonfield
force-pushed
the
expr_depth
branch
from
November 30, 2026 15:44
c0840aa to
a15aa20
Compare
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.
!!!!!a. We could rewrite this to be non-recursive, but it's a nonsensical scenario anyway.cmp_expr andeq_exprcould parse right to left, meaning e.g.3>2>1` gives the wrong result.