Mercurial > hg > octave-lyh
diff src/parse.y @ 5609:bf96b0f9dbd7
[project @ 2006-02-09 02:29:59 by jwe]
author | jwe |
---|---|
date | Thu, 09 Feb 2006 02:30:00 +0000 |
parents | 61d6cebd243b |
children | d01f07aeaec5 |
line wrap: on
line diff
--- a/src/parse.y +++ b/src/parse.y @@ -2572,6 +2572,28 @@ curr_sym_tab->clear (id_name); + if (! lexer_flags.parsing_nested_function + && symtab_context.top () == top_level_sym_tab) + { + symbol_record *sr = top_level_sym_tab->lookup (id_name); + + // Only clear the existing name if it is already defined as a + // function. If there is already a variable defined with the + // same name as a the current function, it will continue to + // shadow this name until the variable is cleared. This means + // that for something like the following at the command line, + // + // f = 13; + // function f () 7, end + // f + // + // F will still refer to the variable F (with value 13) rather + // than the function F, until the variable F is cleared. + + if (sr && sr->is_function ()) + top_level_sym_tab->clear (id_name); + } + symbol_record *sr = fbi_sym_tab->lookup (id_name, true); if (sr)