Commit Graph

2 Commits

Author SHA1 Message Date
Julien Fischer
e876db7873 Adjust bounds checking behaviour of array.fetch_items/4.
Change array.fetch_items/4 to return an empty list for an empty range in the
case where the endpoints of that range are not within the array bounds.

library/array.m:
   As above.

deep_profiler/autopar_types.m:
   Undo Zoltan's recent workaround for the above behaviour.

tests/hard_coded/array_fetch_items.{m,ex}:
   Add tests for this behaviour.
2019-08-16 12:40:36 +10:00
Julien Fischer
3a7254bca2 Improve the documentation for array.fetch_items.
Change the behaviour of the above predicate in the following ways:
- throw an index_out_of_bounds/0 exception instead of a software_error/0
  exception if either index is out of bounds.
- perform the out of bounds check before checking if the third argument is
  less than the second.

Add an more comprehensive test of fetch_items/4.

library/array.m:
    Make it clear that the range of indexes passed to fetch_items is
    inclusive.

    Throw an index_out_of_bounds/0 exception instead of a software_error/1
    exception if either of the indexes is out of bounds.

    Perform the array bounds check first, before checking if the third
    argument is less than the second.

    Document what happens if the upper index is less than the lower one.

    Fix a typo in the documentation of fill_range/4.

    Update the definition of to_list/2 to conform with the above change
    to the array bounds checks.

NEWS:
    Announce the above change to the semantics of fetch_items/0.

tests/hard_coded/Mmakefile:
tests/hard_coded/array_fetch_items.{m,exp}:
    Add a more comprehensive
2018-12-24 06:15:23 +00:00