docs: fix arithmetic update-assignment equivalence (#3682)

The manual said `a op= b` is equivalent to `a |= . op b`. It is actually
equivalent to `(b as $b | a |= . op $b)`: the right-hand side gets `.`
as input, not the value being updated, and each value it outputs gives a
separate result.

This updates the description and adds two examples, `.a += .b` and `.a
+= (1,2)`. `tests/man.test` and `jq.1.prebuilt` are regenerated.

Fixes #2119, fixes #2407
This commit is contained in:
qodelicious authored and GitHub committed 2026-10-22 20:23:52 +02:00
1 parent 94b00aa807
commit e440cccc0a
3 files changed
+48 -3

No files matched your search

+9
View File
@@ -994,6 +994,15 @@ true
{"foo": 42}
{"foo": 43}
.a += .b
{"a": 1, "b": 2}
{"a": 3, "b": 2}
.a += (1,2)
{"a": 0}
{"a": 1}
{"a": 2}
.a = .b
{"a": {"b": 10}, "b": 20}
{"a":20,"b":20}