diff scripts/help/warning_ids.m @ 21990:efce657ceb86

Provide a warning when an array is used in an if/while/until (bug #43098). * errwarn.{cc,h} (warn_array_as_logical, reset_first_array_as_logical_since_keyboard): New functions * error.cc (initialize_default_warning_state): Disable Octave:array-as-logical by default * warning_ids.m: Add new warning Octave:array-as-logical. * input.cc (interactive_input): Reset first_array_as_logical_since_keyboard. * ov-base-mat.cc (octave_base_matrix<MT>::is_true): Call warn_array_as_logical if > 1x1. * ov-base-diag.cc (octave_base_diag<DMT, MT>::is_true): Call warn_array_as_logical if > 1x1. Optimise calculation. * ov-perm.cc (octave_perm_matrix::do_index_op): Call warn_array_as_logical if > 1x1. Optimise calculation. * ov-range.cc (octave_range::is_true): Call warn_array_as_logical if > 1x1. Optimise calculation. * ov-base-sparse (octave_base_sparse<T>::is_true) Call warn_array_as_logical if > 1x1. Check for NaN/NA. * Sparse.cc (Sparse<T>::SparseRep::any_element_is_nan): New function. * Sparse.h (Sparse<T>::SparseRep::any_element_is_nan, Sparse<T>::any_element_is_nan): New functions. * Sparse-b.cc (Sparse<bool>::SparseRep::any_element_is_nan): New function, specialization of the above. * if.tst: New built-in self tests.
author Lachlan Andrew <lachlanbis@gmail.com>
date Wed, 29 Jun 2016 08:50:09 -0700
parents 3e495750cf62
children a937963aacc9
line wrap: on
line diff
--- a/scripts/help/warning_ids.m	Tue Jun 28 16:42:15 2016 -0400
+++ b/scripts/help/warning_ids.m	Wed Jun 29 08:50:09 2016 -0700
@@ -23,6 +23,12 @@
 ## @item Octave:abbreviated-property-match
 ## By default, the @code{Octave:abbreviated-property-match} warning is enabled.
 ##
+## @item Octave:array-as-logical
+## If the @code{Octave:array-to-scalar} warning is enabled,
+## Octave will warn when an array of size greater than 1x1 is used
+## as a truth value in an if, while or until statement.
+## By default, the @code{Octave:array-as-logical} warning is disabled.
+##
 ## @item Octave:array-to-scalar
 ## If the @code{Octave:array-to-scalar} warning is enabled, Octave will
 ## warn when an implicit conversion from an array to a scalar value is