changeset 21814:0b5fd19477fd

when parsing function, check variable status in new function scope (bug #48031) * lex.h, lex.ll (octave_base_lexer::is_variable): New argument, scope. Pass scope to symbol_table::is_variable. (octave_base_lexer::handle_identifier): Pass scope id of function that is being parsed to is_variable.
author John W. Eaton <jwe@octave.org>
date Wed, 01 Jun 2016 19:02:03 -0400
parents 2ba69be3f3e8
children 418b6066e544
files libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll
diffstat 2 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h	Wed Jun 01 18:56:48 2016 -0400
+++ b/libinterp/parse-tree/lex.h	Wed Jun 01 19:02:03 2016 -0400
@@ -578,7 +578,7 @@
 
   bool inside_any_object_index (void);
 
-  bool is_variable (const std::string& name);
+  bool is_variable (const std::string& name, symbol_table::scope_id scope);
 
   int is_keyword_token (const std::string& s);
 
--- a/libinterp/parse-tree/lex.ll	Wed Jun 01 18:56:48 2016 -0400
+++ b/libinterp/parse-tree/lex.ll	Wed Jun 01 19:02:03 2016 -0400
@@ -2476,9 +2476,10 @@
 }
 
 bool
-octave_base_lexer::is_variable (const std::string& name)
+octave_base_lexer::is_variable (const std::string& name,
+                               symbol_table::scope_id scope)
 {
-  return (symbol_table::is_variable (name)
+  return (symbol_table::is_variable (name, scope)
           || (pending_local_variables.find (name)
               != pending_local_variables.end ()));
 }
@@ -3109,7 +3110,7 @@
   // function call with the argument "+1".
 
   if (at_beginning_of_statement
-      && (! (is_variable (ident)
+      && (! (is_variable (ident, sid)
              || ident == "e" || ident == "pi"
              || ident == "I" || ident == "i"
              || ident == "J" || ident == "j"