changeset 5006:2bcd013bc867

[project @ 2004-09-17 02:59:53 by jwe]
author jwe
date Fri, 17 Sep 2004 02:59:53 +0000
parents 62da6b854fdb
children f8c27dad3643
files src/ChangeLog src/parse.y src/symtab.cc
diffstat 3 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Sep 17 01:57:41 2004 +0000
+++ b/src/ChangeLog	Fri Sep 17 02:59:53 2004 +0000
@@ -1,5 +1,8 @@
 2004-09-16  John W. Eaton  <jwe@octave.org>
 
+	* parse.y (frob_function): Clear id_name from curr_sym_tab, not
+	top_level_sym_tab.
+
 	* symtab.cc (maybe_list): Count sizes using size_t, not int.
 
 	* variables.cc (symbol_out_of_date): Always look in LOADPATH.
--- a/src/parse.y	Fri Sep 17 01:57:41 2004 +0000
+++ b/src/parse.y	Fri Sep 17 02:59:53 2004 +0000
@@ -2715,7 +2715,21 @@
 
   fcn->stash_function_name (id_name);
 
-  top_level_sym_tab->clear (id_name);
+  // Enter the new function in fbi_sym_tab.  If there is already a
+  // variable of the same name in the current symbol table, we won't
+  // find the new function when we try to call it, so we need to clear
+  // the old symbol from the current symbol table.  Note that this
+  // means that for things like
+  //
+  //   function f () eval ("function g () 1, end"); end
+  //   g = 13;
+  //   f ();
+  //   g
+  //
+  // G will still refer to the variable G (with value 13) rather
+  // than the function G, until the variable G is cleared.
+
+  curr_sym_tab->clear (id_name);
 
   symbol_record *sr = fbi_sym_tab->lookup (id_name, true);
 
--- a/src/symtab.cc	Fri Sep 17 01:57:41 2004 +0000
+++ b/src/symtab.cc	Fri Sep 17 02:59:53 2004 +0000
@@ -1554,9 +1554,9 @@
 	    }
 
 	  os << "\nTotal is "
-	     << elements << (elements > 1 ? " elements" : "element")
+	     << elements << (elements == 1 ? " element" : " elements")
 	     << " using "
-	     << bytes << (bytes > 1 ? " bytes" : "byte")
+	     << bytes << (bytes == 1 ? " byte" : " bytes")
 	     << "\n";
 
 	  status = 1;