#1107 sort on arrays that have removed items may raise condition 98.975

None
wont-fix
nobody
None
none
1
2012-08-23
2012-08-23
No

Running the following program will raise the error condition 98.975, if the first or second element in the array get removed. It works, if the third element gets removed.

----------- cut here ----------

a=.array~of("one", "two", "three")
do e over a~sort
   say e
end
say "--- now doing a~remove(...)"

a~remove(1) -- condition: 98.975:  Missing array element at position 2
-- a~remove(2) -- condition: 98.975:  Missing array element at position 2
-- a~remove(3) -- works in this case

say "a~sort:"
do e over a~sort
   say e
end

say "a~sortWith(.caselessComparator~new):"
do e over a~sortWith(.caselessDescendingComparator~new)
   say e
end

----------- cut here ----------

The output on 4.1.1 (WinXP) running the above program is:

----------- cut here ----------

one
three
two
--- now doing a~remove(...)
a~sort:
    12 *-*   do e over a~sort
Error 98 running F:\test\orx\misc\frankClarke\testArr.rex line 12:  Execution error
Error 98.975:  Missing array element at position 1

----------- cut here ----------

Discussion

  • Rick McGuire
    Rick McGuire
    2012-08-23

    The sort only works up to the last element of the array. Removing the third element in this case just shortens the size of the array rather than creating a "hole" in the set of elements.

     


Anonymous


Cancel   Add attachments