# HG changeset patch # User Michael Goffioul # Date 1391897401 18000 # Node ID d5aa615dcf4c139c4790614dc5252733da2205bb # Parent e76d50d65278f53f40035b6a0ad3152fda2cc2c7 Fix package function call with magic "end" in arguments. * ov-classdef.cc (cdef_package::cdef_package_rep::meta_subsref): Don't handle the case "pack.fun", leave it up to the parse-tree to execute the package function. * pt-idx.cc (tree_index_expression::rvalue): If the (temporary) result of indexing is a function object, make sure it is executed if required. diff -r e76d50d65278 -r d5aa615dcf4c libinterp/octave-value/ov-classdef.cc --- a/libinterp/octave-value/ov-classdef.cc Sat Feb 08 13:35:00 2014 -0800 +++ b/libinterp/octave-value/ov-classdef.cc Sat Feb 08 17:10:01 2014 -0500 @@ -3443,7 +3443,13 @@ if (! error_state) { - if (type.size () == 1 || + // NOTE: the case where the package query is the last + // part of this subsref index is handled in the parse + // tree, because there is some logic to handle magic + // "end" that makes it impossible to execute the + // function call at this stage. + + if (type.size () > 1 && ! fcn->is_postfix_index_handled (type[1])) { octave_value_list tmp_args; diff -r e76d50d65278 -r d5aa615dcf4c libinterp/parse-tree/pt-idx.cc --- a/libinterp/parse-tree/pt-idx.cc Sat Feb 08 13:35:00 2014 -0800 +++ b/libinterp/parse-tree/pt-idx.cc Sat Feb 08 17:10:01 2014 -0500 @@ -363,7 +363,7 @@ // that argument list so we can pass the appropriate // value to the built-in end function. - const octave_value_list tmp_list + octave_value_list tmp_list = tmp.subsref (type.substr (tmpi, i - tmpi), idx, nargout); tmp = tmp_list.length () ? tmp_list(0) : octave_value (); @@ -375,6 +375,26 @@ if (error_state) break; + + if (tmp.is_function ()) + { + octave_function *fcn = tmp.function_value (true); + + if (fcn && ! fcn->is_postfix_index_handled (type[i])) + { + octave_value_list empty_args; + + tmp_list = tmp.do_multi_index_op (1, empty_args); + tmp = (tmp_list.length () + ? tmp_list(0) : octave_value ()); + + if (tmp.is_cs_list ()) + gripe_indexed_cs_list (); + + if (error_state) + break; + } + } } } @@ -412,8 +432,27 @@ } if (! error_state) - retval = tmp.subsref (type.substr (tmpi, n - tmpi), idx, nargout, - lvalue_list); + { + retval = tmp.subsref (type.substr (tmpi, n - tmpi), idx, nargout, + lvalue_list); + + octave_value val = retval.length () ? retval(0) : octave_value (); + + if (! error_state && val.is_function ()) + { + octave_function *fcn = val.function_value (true); + + if (fcn) + { + octave_value_list empty_args; + + retval = (lvalue_list + ? val.do_multi_index_op (nargout, empty_args, + lvalue_list) + : val.do_multi_index_op (nargout, empty_args)); + } + } + } } return retval;