Mercurial > octave
changeset 29369:c75996cbe3ba
Emit more specific error when two different integer types used in range (bug #59899).
* ov.cc (colon_op): Add a case to switch statement for "btyp_unknown" and emit
error about incompatible types.
* range.tst: Add BIST tests for incompatible and invalid range types.
Add xtest BIST tests for bug #59899 for code that still needs to be
written.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 13 Feb 2021 18:22:39 -0800 |
parents | 30afb3804d6e |
children | d35ed8538d69 |
files | libinterp/octave-value/ov.cc test/range.tst |
diffstat | 2 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ov.cc Sat Feb 13 13:59:49 2021 -0800 +++ b/libinterp/octave-value/ov.cc Sat Feb 13 18:22:39 2021 -0800 @@ -3103,6 +3103,9 @@ case btyp_char: return make_range<char> (base, increment, limit, is_for_cmd_expr); + case btyp_unknown: + error ("incompatible types found in range expression"); + default: error ("invalid types found in range expression"); }
--- a/test/range.tst Sat Feb 13 13:59:49 2021 -0800 +++ b/test/range.tst Sat Feb 13 18:22:39 2021 -0800 @@ -476,3 +476,18 @@ %!error <range with infinite number of elements cannot be stored> -inf:pt3:zero %!error <range with infinite number of elements cannot be stored> -inf:pt3:one %!error <range with infinite number of elements cannot be stored> -inf:pt3:inf + +## Tests with different input classes +%!error <invalid types found in range> ({1}:1:5) +%!error <invalid types found in range> (1:{1}:5) +%!error <invalid types found in range> (1:1:{5}) +%!error <incompatible types found in range> (int8(1):int16(1):5) +%!error <incompatible types found in range> (int8(1):1:int16(5)) +## Convert to ordinary %!error test when this behavior is coded +%!xtest <59899> +%! fail ('(int8(1):0.4:5)', 'floating point values must be integers when used with integer data types'); +%! fail ('(int8(1):1:5.5)', 'floating point values must be integers when used with integer data types'); +%!xtest <59899> +%! fail ('(uint8(5):-1:1)', 'start, increment, and end values must be within the range of the integer data type'); +%! fail ('(-5:1:uint8(1)', 'start, increment, and end values must be within the range of the integer data type'); +%! fail ('(uint8(255):1:260', 'start, increment, and end values must be within the range of the integer data type');