Mercurial > octave
changeset 23684:c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
* pt-eval.cc (tree_evaluator::visit_index_expression):
Handle any remaining arguments in index expression for final function
call.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 24 Jun 2017 11:39:32 -0400 |
parents | ffd27f53fc79 |
children | a94ed7424d63 |
files | libinterp/parse-tree/pt-eval.cc |
diffstat | 1 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-eval.cc Fri Jun 23 18:18:07 2017 -0400 +++ b/libinterp/parse-tree/pt-eval.cc Sat Jun 24 11:39:32 2017 -0400 @@ -1368,6 +1368,9 @@ try { retval = base_expr_val.subsref (type.substr (beg, n-beg), idx, nargout); + + beg = n; + idx.clear (); } catch (octave::index_exception& e) // range problems, bad index type, etc. { @@ -1384,7 +1387,23 @@ octave_function *fcn = val.function_value (true); if (fcn) - retval = fcn->call (*this, nargout); + { + octave_value_list final_args; + + if (! idx.empty ()) + { + if (n - beg != 1) + error ("unexpected extra index at end of expression"); + + if (type[beg] != '(') + error ("invalid index type '%c' for function call", + type[beg]); + + final_args = idx.front (); + } + + retval = fcn->call (*this, nargout, final_args); + } } m_value_stack.push (retval);