Mercurial > octave-nkf
changeset 16755:787168f5f858
tag symbols in indexed assignments as variables (bug #39240)
* pt-arg-list.cc (tree_argument_list::variable_names): Also return the
symbol names from index expressions.
* parser.tst: New test.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 12 Jun 2013 10:50:29 -0400 |
parents | 022dba56de1e |
children | d56cbc17566e |
files | libinterp/parse-tree/pt-arg-list.cc test/parser.tst |
diffstat | 2 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-arg-list.cc Wed Jun 12 10:03:50 2013 -0400 +++ b/libinterp/parse-tree/pt-arg-list.cc Wed Jun 12 10:50:29 2013 -0400 @@ -298,6 +298,13 @@ retval.push_back (id->name ()); } + else if (elt->is_index_expression ()) + { + tree_index_expression *idx_expr + = dynamic_cast<tree_index_expression *> (elt); + + retval.push_back (idx_expr->name ()); + } } return retval;
--- a/test/parser.tst Wed Jun 12 10:03:50 2013 -0400 +++ b/test/parser.tst Wed Jun 12 10:50:29 2013 -0400 @@ -257,3 +257,9 @@ %! R = @(rot) [cos(rot) -sin(rot); sin(rot) cos(rot)]; %! assert (R(pi/2), [cos(pi/2), -sin(pi/2); sin(pi/2),cos(pi/2)]); +## Check that xyz is tagged as a variable in the parser. Both +## expressions must remain on one line for this test to work as +## intended. +%!test +%! xyz(1) = 1; xyz /= 1; +%! assert (xyz, 1);