Improve unary with sign expression handling#2224
Open
xenova wants to merge 1 commit into
Open
Conversation
jamiejet28-create
approved these changes
Jun 9, 2026
nico-martin
approved these changes
Jun 10, 2026
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.
fixes
{{ 0 in axes or -4 in axes }}Note
Medium Risk
Changes expression parsing precedence and unary evaluation across lexer/parser/runtime; behavior shifts for any template using
+/-before identifiers orin, though tests lock expected outcomes.Overview
Fixes templates like
{% if 0 in axes or -4 in axes %}by treating leading+/-as unary sign on the following value, not as binary subtraction glued toin.The parser adds
parseUnarySignExpression(used before filters) so expressions such as-4 in axes,-apple | abs, and-(apple + 1) in arrbuildUnaryExpressionnodes. The lexer now folds fractional digits after a unary sign into one numeric token (e.g.-1.5). The runtime evaluates unary+/-on numbers and booleans; float formatting andFloatValue.toString()handle-0.0and whole-number floats consistently. Coverage is extended viaUNARY_SIGN_EXPRESSIONSintemplates.test.js.Reviewed by Cursor Bugbot for commit 48987c9. Bugbot is set up for automated code reviews on this repo. Configure here.