Skip to content

Commit faca28b

Browse files
Fix Array.Less slice out of bounds (#362)
1 parent b102617 commit faca28b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

rel/value_set_array.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func (a Array) Less(v Value) bool {
212212
return a.offset < b.offset
213213
}
214214
n := len(a.values)
215-
if n < len(b.values) {
215+
if n > len(b.values) {
216216
n = len(b.values)
217217
}
218218
for i, av := range a.values[:n] {

syntax/expr_set_array_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,8 @@ func TestArrayWithHoles(t *testing.T) {
4242
AssertCodesEvalToSameValue(t, `[10, 11, 12]`, `[10, , 12] with (@: 1, @item: 11)`)
4343
AssertCodesEvalToSameValue(t, `[10, 11, 12]`, `[10, , 12, , , ] with (@: 1, @item: 11)`)
4444
}
45+
46+
func TestSetOfArrays(t *testing.T) {
47+
// This tests an error when stringifying sets of arrays.
48+
AssertCodesEvalToSameValue(t, `'{[1], [1, 1]}'`, `$'${{[1, 1], [1]}}'`)
49+
}

0 commit comments

Comments
 (0)