diff --git a/libinterp/corefcn/variables.cc b/libinterp/corefcn/variables.cc --- a/libinterp/corefcn/variables.cc +++ b/libinterp/corefcn/variables.cc @@ -233,26 +233,35 @@ symbol_exist (octave::interpreter& inter // We shouldn't need to look in the global symbol table, since any name // that is visible in the current scope will be in the local symbol table. - // Command line function which Matlab does not support - if (search_any) - { - octave_value val = symtab.find_cmdline_function (name); - - if (val.is_defined ()) - return 103; - } - if (search_any || search_file || search_dir) { - octave::tree_evaluator& tw = interp.get_evaluator (); + std::string file_name; - std::string file_name = tw.lookup_autoload (name); - - if (file_name.empty ()) + if (search_any || search_file) { octave::load_path& lp = interp.get_load_path (); - file_name = lp.find_fcn (name); + // Class constructor. + file_name = lp.find_method (name, name); + + if (search_any && file_name.empty ()) + { + // Command line function which Matlab does not support + octave_value val = symtab.find_cmdline_function (name); + + if (val.is_defined ()) + return 103; + } + + if (file_name.empty ()) + { + octave::tree_evaluator& tw = interp.get_evaluator (); + + file_name = tw.lookup_autoload (name); + } + + if (file_name.empty ()) + file_name = lp.find_fcn (name); } size_t len = file_name.length (); @@ -303,14 +312,9 @@ symbol_exist (octave::interpreter& inter return 0; } - if (search_any || search_builtin) - { - if (symtab.is_built_in_function_name (name)) - return 5; - - if (search_builtin) - return 0; - } + if ((search_any || search_builtin) + && symtab.is_built_in_function_name (name)) + return 5; return 0; }