SIGN IN SIGN UP

ast/term: don't sort an object's keys slice in-place (#3823)

* ast/term: sort-on-insert for object.keys slice

Instead of sorting on each call including Compare() or String(), we'll sort the key
slice on insertion of a new value.

* testcases: add case

As observed in the original issue, the failure does not happen on every
run. To observe the added test case _failing_ on branch main, use a test
call like

    go test -v ./topdown -run TestRego/partialsetdoc:_object_sort_while_iter -count=10 -v

The added `sort_bindings: true` is not required for the topdown eval,
but when executing this on the wasm engine, the (unspecified, non-
guaranteed) order is reversed.

Fixes #3819

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
S
Stephan Renatus committed
bff539985626b2a4b8a76eebcb884a5968f0d484
Parent: 0e2d0bd
Committed by GitHub <noreply@github.com> on 9/27/2021, 4:36:18 PM