bugGNU Octave - Bugs: bug #46849, Shadowing warning on every command...

 
 

bug #46849: Shadowing warning on every command for function in +package directory

Submitted by:  Richard <crobar>
Submitted on:  Fri 08 Jan 2016 03:06:35 PM UTC  
 
Category:  Interpreter Severity:  3 - Normal
Priority:  6 Item Group:  Unexpected Error
Status:  Patch Submitted Assigned to:  None
Originator Name:  Richard Crozier Open/Closed:  Open
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 15 Aug 2018 07:34:20 PM UTC, comment #3: 

Adding jwe to the CC list and increasing the priority.  The whole point of namespaces is to allow for the same names to exist without provoking a conflict.

A little extra information, the shadowing warning is only for built-in (i.e, C++ functions).  I can put an additional 'ls.m' m-file in the +testpkg directory and I don't get a shadowed warning.

Rik <rik5>
Project Administrator
Mon 14 May 2018 01:41:35 PM UTC, comment #2: 

I modified load-path.cc around line 1686 to check for a '+' in the first character of the directory name when deciding whether the function is shadowed like this:

                    symbol_table& symtab
                      = __get_symbol_table__ ("load_path::package_info::add_to_fcn_map");

                    // check it is not a package directory
                    std::string last_dir_name;
                    std::size_t lastDirPos = dir_name.find_last_of("/");

                    if (lastDirPos == std::string::npos)
                      {
                        // make sure there's something to test
                        last_dir_name = "-";
                      }
                    else
                      {
                        last_dir_name = dir_name.substr(lastDirPos+1, dir_name.length()-1);
                      }

                    if (last_dir_name[0] != '+')
                      {
                        if (symtab.is_built_in_function_name (base))
                          {
                            std::string fcn_path = sys::file_ops::concat (dir_name, fname);

                            warning_with_id ("Octave:shadowed-function",
                                             "function %s shadows a built-in function",
                                             fcn_path.c_str ());
                          }
                      }

And the warnings went away, no doubt this is not the best way to fix this though.

Richard <crobar>
Mon 14 May 2018 12:31:26 PM UTC, comment #1: 

This issue still exists in the stable dev version of Octave, I've attached a session running octave to demonstrate the problem. I get over 100 lines of warnings when launching Octave and four or five lines of warnings when running every command, even just x = 1; etc., nothing to do with the 'shadowed' functions (which aren't shadowed, they are in a package namespace).

(file #44154)

Richard <crobar>
Fri 08 Jan 2016 03:06:35 PM UTC, original submission:  

I think I have noticed an issue with incorrectly warning about shadowing of function in +package directories in the dev build (I am going to use +package to refer to Matlab style package directories, as opposed to Octave packages).

If I have a function in +package I get a shadowing warning against functions of the same name in the global namespace. In recent builds this is issued on every single command. I have done the following to test this.

create a directory call +testpckg

Created a function file 'inverse.m' in this directory (there is an Octave built-in inverse function). This new function should be in the testpkg namespace and not clash with the built-in.

The directory containing +testpckg is added to the path on startup by running genpath on a higher level directory. I have checked that the directory +testpckg is not in the path, but the directory containing it is.

On startup I get the warning:

warning: function .../mfiles/octave-test/+testpckg/inverse.m shadows a built-in function

This isn't so bad, but as I mentioned, I now also get the same warning with every single command entered at the Octave prompt.

hg id reports 63374982750b tip @

Richard <crobar>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by amro_octave
  • -email is unavailable- added by crobar (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-15 rik5 Priority5 - Normal => 6
        StatusConfirmed => Patch Submitted
        Carbon-Copy- => Added jwe
    2018-07-08 mtmiller Dependencies- => bugs #54270 is dependent
    2018-05-14 mtmiller Carbon-CopyRemoved 80942 => -
    2018-05-14 mtmiller Item GroupNone => Unexpected Error
        StatusNone => Confirmed
    2018-05-14 crobar Attached File- => Added octave_shadow_warnings.txt, #44154
    2016-12-09 amro_octave Carbon-Copy- => Added amro_octave
    2016-07-03 mtmiller Dependencies- => bugs #48390 is dependent
    2016-04-04 mtmiller Dependencies- => bugs #47622 is dependent

    Back to the top


    Powered by Savane 3.5