changeset 29854:2bb72743d3eb

who() should not display duplicate named variables from different scopes (bug #60845). * stack-frame.cc (make_symbol_info_list): Add test to check if frame_offset() is greater than 0 (we're in a nested function) and don't display additional variables from those frames.
author John W. Eaton <jwe@octave.org>
date Mon, 05 Jul 2021 08:46:16 -0700
parents b918ef934b71
children 1e0530d86229
files libinterp/corefcn/stack-frame.cc
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/stack-frame.cc	Mon Jul 05 09:02:55 2021 -0400
+++ b/libinterp/corefcn/stack-frame.cc	Mon Jul 05 08:46:16 2021 -0700
@@ -1098,13 +1098,14 @@
       {
         octave_value value = varval (sym);
 
-        if (value.is_defined ())
-          {
-            symbol_info syminf (sym.name (), value, sym.is_formal (),
-                                is_global (sym), is_persistent (sym));
-
-            symbol_stats.append (syminf);
-          }
+        if (! value.is_defined ()
+            || (is_user_fcn_frame () && sym.frame_offset () > 0))
+          continue;
+
+        symbol_info syminf (sym.name (), value, sym.is_formal (),
+                            is_global (sym), is_persistent (sym));
+
+        symbol_stats.append (syminf);
       }
 
     return symbol_stats;