diff --git a/libinterp/corefcn/symtab.h b/libinterp/corefcn/symtab.h --- a/libinterp/corefcn/symtab.h +++ b/libinterp/corefcn/symtab.h @@ -1466,11 +1466,16 @@ public: inst->do_erase_persistent (name); } + static bool is_variable (const std::string& name, scope_id scope) + { + symbol_table *inst = get_instance (scope); + + return inst ? inst->do_is_variable (name) : false; + } + static bool is_variable (const std::string& name) { - symbol_table *inst = get_instance (xcurrent_scope); - - return inst ? inst->do_is_variable (name) : false; + return is_variable (name, xcurrent_scope); } static bool diff --git a/libinterp/parse-tree/lex.h b/libinterp/parse-tree/lex.h --- a/libinterp/parse-tree/lex.h +++ b/libinterp/parse-tree/lex.h @@ -578,7 +578,7 @@ public: 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); diff --git a/libinterp/parse-tree/lex.ll b/libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -2476,9 +2476,10 @@ octave_base_lexer::inside_any_object_ind } 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 @@ octave_base_lexer::handle_identifier (vo // 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"