changeset 23778:711227992c1d

Fix static class method argument inaccessible (bug #51192). * pt-eval.cc (tree_evaluator::visit_index_expression): make sure the classdef meta type is not an indexing_object. * test/bug-51192/bug-51192.tst, test/bug-51192/class_bug51192.m: new files for simple test of invoking a static method on a class name with arguments. * test/module.mk: Add bug-51192 tests to build system.
author Piotr Held <pjheld@gmail.com>
date Thu, 20 Jul 2017 16:45:00 -0700
parents cda0614beaec
children 7becd026c8ba
files libinterp/parse-tree/pt-eval.cc test/bug-51192/bug-51192.tst test/bug-51192/class_bug51192.m test/bug-51192/module.mk
diffstat 4 files changed, 37 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-eval.cc	Thu Jul 20 21:25:06 2017 -0700
+++ b/libinterp/parse-tree/pt-eval.cc	Thu Jul 20 16:45:00 2017 -0700
@@ -1335,7 +1335,9 @@
     if (base_expr_val.is_undefined ())
       base_expr_val = evaluate (expr);
 
-    bool indexing_object = base_expr_val.isobject () || base_expr_val.isjava ();
+    bool indexing_object = base_expr_val.isobject () || base_expr_val.isjava ()
+                           || base_expr_val.is_classdef_meta(); 
+                           // ^ this check is for static methods on class name
 
     std::list<octave_value_list> idx;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-51192/bug-51192.tst	Thu Jul 20 16:45:00 2017 -0700
@@ -0,0 +1,22 @@
+## Copyright (C) 2017 Piotr Held
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or
+## (at your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+%!test
+%! a = class_bug51192 ();
+%! a.foo ("asd")
+%! class_bug51192.foo ("asd");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-51192/class_bug51192.m	Thu Jul 20 16:45:00 2017 -0700
@@ -0,0 +1,7 @@
+classdef class_bug51192 
+  methods (Static)
+    function foo (val)
+      val;
+    endfunction
+  endmethods
+endclassdef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-51192/module.mk	Thu Jul 20 16:45:00 2017 -0700
@@ -0,0 +1,5 @@
+bug_51192_TEST_FILES = \
+  %reldir%/bug-51192.tst \
+  %reldir%/class_bug51192.m
+
+TEST_FILES += $(bug_51192_TEST_FILES)