Skip to content

fix: preserve arithmetic unary operator boundaries - #21

Open
everton-dgn wants to merge 1 commit into
webpro-nl:mainfrom
everton-dgn:fix/preserve-arithmetic-unary-operators
Open

everton-dgn wants to merge 1 commit into
webpro-nl:mainfrom
everton-dgn:fix/preserve-arithmetic-unary-operators

Conversation

@everton-dgn

Copy link
Copy Markdown

Printing (( - -x )) currently produces (( --x )). With x=7, that changes the result to 6 and decrements x. The same issue turns + +x into an increment.

Keep a separator when a unary + or - would otherwise join the same leading sign on its operand. The regression tests cover the operator tree after reparsing, nested signs, increment/decrement operands and arithmetic for loops.

Validation: 2,063 tests, build/types and lint passed on Node 24. The package smoke test passed on Node 14.21.3, and execution checks against Bash 3.2 and 5.1 preserve both values and mutations for the covered expressions.

Printing `(( - -x ))` currently produces `(( --x ))`. With `x=7`, that changes the result to 6 and decrements x. The same issue turns `+ +x` into an increment.

Keep a separator when a unary + or - would otherwise join the same leading sign on its operand. The regression tests cover the operator tree after reparsing, nested signs, increment/decrement operands and arithmetic for loops.

Validation: 2,063 tests, build/types and lint passed on Node 24. The package smoke test passed on Node 14.21.3, and execution checks against Bash 3.2 and 5.1 preserve both values and mutations for the covered expressions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant