octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #58296] Improve description of warning state


From: Rik
Subject: [Octave-bug-tracker] [bug #58296] Improve description of warning state
Date: Sun, 3 May 2020 13:23:12 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko

Follow-up Comment #4, bug #58296 (project octave):

Re-posting my comment.

Case 1 : non-existent warnings

Octave doesn't have a full list of all warnings that can ever be produced
because the list is dynamic.  You could open up an editor and write a new
m-file which defines a new warning ID and Octave has no way of knowing about
this.  Similarly, you could use addpath to add a whole directory of new
functions, but in order to understand whether a new warning ID had been
declared would require parsing every single function and storing the
information away somewhere.  

Incidentally, Matlab behaves the same as Octave.  Try something like


warning ('query', 'MYID:test')


and it will report that the warning is enabled.

case 2 : turning on all warnings

This behavior is also Matlab compatible.  The warning ID 'all' is special. 
When you ask for


warning query all


Octave or Matlab looks at the state of the 'all' ID (either 'on' or 'off') and
then reports only the warnings which are in a different state.  The default
warning state is 'on' and so Octave only reports on the warning IDs which are
set to 'off'.  See Octave session below


octave:2> ws = warning ('query')
ws =

  1x15 struct array containing the fields:

    identifier
    state

octave:3> ws.identifier
ans = all
ans = Octave:array-as-logical
ans = Octave:array-to-scalar
ans = Octave:array-to-vector
ans = Octave:imag-to-real
ans = Octave:language-extension
ans = Octave:missing-semicolon
ans = Octave:neg-dim-as-zero
ans = Octave:resize-on-range-error
ans = Octave:separator-insert
ans = Octave:single-quote-string
ans = Octave:str-to-num
ans = Octave:mixed-string-concat
ans = Octave:variable-switch-label
ans = Octave:abbreviated-property-match

octave:4> ws.state
ans = on
ans = off
ans = off
ans = off
ans = off
ans = off
ans = off
ans = off
ans = off
ans = off
ans = off
ans = off
ans = off
ans = off
ans = off


When you execute


warning on all


then all warning IDs are in the same state as the special 'all' ID and so
Octave only reports on the one ID.

Case 3 : shadowing warning

The shadowing warning is issued when a new function file shadows a built-in
function, and not when a variable shadows a built-in function.  Matlab behaves
similarly in that it lets you do this


sin = 5


To show this in Octave, execute this from a shell


mkdir ../+pkg
touch ../+pkg/sin.m


Next, start Octave, which will be fine.  But then execute


octave:1> addpath ..
warning: function /home/rik/wip/Projects_Mine/+pkg/sin.m shadows a built-in
function
warning: function /home/rik/wip/Projects_Mine/+pkg/sin.m shadows a built-in
function


Case 4 : only 14 warnings reported

This is the same issue as in Case 1 and Case 2.  Octave only reports warning
IDs which differ from the current state of 'all'.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58296>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]