# HG changeset patch # User John W. Eaton # Date 1328733748 18000 # Node ID acc26b860afa76f3dc131975b0f29b0681fcfcd5 # Parent 2cd56a5e3a66f70336e91269adf311d6606a5a68 fix indexed assignment bug (bug #35482) * pt-idx.cc (make_value_list): New argument, rvalue. Only require object to be defined if rvalue is true. (tree_index_expression::lvalue): Call make_value_list with rvalue argument set to false. New test. diff -r 2cd56a5e3a66 -r acc26b860afa src/pt-idx.cc --- a/src/pt-idx.cc Tue Feb 07 11:41:33 2012 -0500 +++ b/src/pt-idx.cc Wed Feb 08 15:42:28 2012 -0500 @@ -177,13 +177,13 @@ static inline octave_value_list make_value_list (tree_argument_list *args, const string_vector& arg_nm, - const octave_value *object) + const octave_value *object, bool rvalue = true) { octave_value_list retval; if (args) { - if (object && args->has_magic_end () && object->is_undefined ()) + if (rvalue && object && args->has_magic_end () && object->is_undefined ()) gripe_invalid_inquiry_subscript (); else retval = args->convert_to_const_vector (object); @@ -476,7 +476,7 @@ case '(': { octave_value_list tidx - = make_value_list (*p_args, *p_arg_nm, &tmp); + = make_value_list (*p_args, *p_arg_nm, &tmp, false); idx.push_back (tidx); @@ -496,7 +496,7 @@ case '{': { octave_value_list tidx - = make_value_list (*p_args, *p_arg_nm, &tmp); + = make_value_list (*p_args, *p_arg_nm, &tmp, false); if (tmp.is_undefined ()) { @@ -601,6 +601,18 @@ /* %!test +%! clear x +%! clear y +%! y = 3; +%! x(y(end)) = 1; +%! assert (x, [0, 0, 1]); +%! clear x +%! clear y +%! y = {3}; +%! x(y{end}) = 1; +%! assert (x, [0, 0, 1]); + +%!test %! x = {1, 2, 3}; %! [x{:}] = deal (4, 5, 6); %! assert (x, {4, 5, 6});