mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 01:13:30 +00:00
Fix an incorrect error message in an exception.
library/version_array2d.m:
The row or column out of bounds messages are off by one; fix that.
tests/hard_coded/version_array2d_test.exp:
Conform to the above change.
This commit is contained in:
@@ -425,14 +425,14 @@ unsafe_rewind(version_array2d(NumRows, NumColumns, VersionArray)) =
|
||||
:- pred out_of_bounds_error(string::in, string::in, int::in, int::in)
|
||||
is erroneous.
|
||||
|
||||
out_of_bounds_error(PredName, RowOrColumn, Index, Max) :-
|
||||
out_of_bounds_error(PredName, RowOrColumn, Index, NumRowsOrColumns) :-
|
||||
% Note: we deliberately do not include the array element type name in the
|
||||
% error message here, for performance reasons: using the type name could
|
||||
% prevent the compiler from optimizing away the construction of the
|
||||
% type_info in the caller, because it would prevent unused argument
|
||||
% elimination.
|
||||
string.format("%s: %s index %d not in range [0, %d]",
|
||||
[s(PredName), s(RowOrColumn), i(Index), i(Max)], Msg),
|
||||
[s(PredName), s(RowOrColumn), i(Index), i(NumRowsOrColumns - 1)], Msg),
|
||||
throw(index_out_of_bounds(Msg)).
|
||||
|
||||
%---------------------------------------------------------------------------%
|
||||
|
||||
@@ -64,16 +64,16 @@ misshapen init: found exception as expected:
|
||||
software_error("function `version_array2d.version_array2d\'/1: non-rectangular list of lists")
|
||||
|
||||
out-of-bounds test 1: found exception as expected:
|
||||
index_out_of_bounds("version_array2d.lookup: column index -1 not in range [0, 4]")
|
||||
index_out_of_bounds("version_array2d.lookup: column index -1 not in range [0, 3]")
|
||||
|
||||
out-of-bounds test 2: found exception as expected:
|
||||
index_out_of_bounds("version_array2d.set: column index -1 not in range [0, 4]")
|
||||
index_out_of_bounds("version_array2d.set: column index -1 not in range [0, 3]")
|
||||
|
||||
out-of-bounds test 3: found exception as expected:
|
||||
index_out_of_bounds("version_array2d.uset: column index 9 not in range [0, 4]")
|
||||
index_out_of_bounds("version_array2d.uset: column index 9 not in range [0, 3]")
|
||||
|
||||
out-of-bounds test 4: found exception as expected:
|
||||
index_out_of_bounds("version_array2d.lookup: row index -1 not in range [0, 4]")
|
||||
index_out_of_bounds("version_array2d.lookup: row index -1 not in range [0, 3]")
|
||||
|
||||
out-of-bounds test 5: found exception as expected:
|
||||
index_out_of_bounds("version_array2d.ulookup: row index 4 not in range [0, 4]")
|
||||
index_out_of_bounds("version_array2d.ulookup: row index 4 not in range [0, 3]")
|
||||
|
||||
Reference in New Issue
Block a user