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

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

[Octave-bug-tracker] [bug #61842] New "too many inputs" error message wr


From: Rik
Subject: [Octave-bug-tracker] [bug #61842] New "too many inputs" error message wrong with anonymous functions
Date: Tue, 18 Jan 2022 11:50:25 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36

Follow-up Comment #12, bug #61842 (project octave):

@jwe: It was just a minor wish to get the anonymous function name, but if it
is too difficult then we can skip it.  Giving the location where the anonymous
function is defined would be enough.  

I think we should try and keep the printed message to be nearly the same as
for a regular function.  For the text I would propose something like


error: called from
  @<anonymous function> defined in FUNCTION_NAME at line L column C


FUNCTION_NAME would be the current reporting structure which is the name of
the m-file without the ".m" extension or the notation using '>' for
subfunctions.  I would use the line and column of the '@' character as you
suggest.

Sample file in tst_err_reporting.m


function tst_err_reporting (do_anon = true)
  disp ("Entered function 'tst_err_reporting'");

  subfunction1 (do_anon);

endfunction

function subfunction1 (do_anon)
  disp ("Entered function 'tst_err_reporting>subfunction1'");
 
  fanon = @(x) x + 1;

  if (do_anon)
    fanon (1, 2);   # Will cause a parse error
  else
    error ("calling error() function from 'subfunction1'");
  endif

endfunction


This can be called with input parameter true or false to see the  different
report mechanisms.


octave:1> tst_err_reporting (false)
error: calling error() function from 'subfunction1'
error: called from
    tst_err_reporting>subfunction1 at line 16 column 5
    tst_err_reporting at line 4 column 3
Entered function 'tst_err_reporting'
Entered function 'tst_err_reporting>subfunction1'
octave:2> tst_err_reporting (true)
error: @<anonymous>: function called with too many inputs
error: called from
    subfunction1>@<anonymous>
    tst_err_reporting>subfunction1 at line 14 column 5
    tst_err_reporting at line 4 column 3
Entered function 'tst_err_reporting'
Entered function 'tst_err_reporting>subfunction1'


Currently the callstack from error() correctly identifies the file and
function "tst_err_reporting>subfunction1" but the report from an error in an
anonymous function leaves off the main function name
"subfunction1>@<anonymous>" making it slightly harder to find the source of
the problem.

My proposal would be something like


    tst_err_reporting>subfunction1>@<anonymous> at line 11 column 11


In my ideal world we could swap out "anonymous" for the name of the variable
so it would read "@<fanon>" in this example.  But, that's gravy.

(file #52677)
    _______________________________________________________

Additional Item Attachment:

File name: tst_err_reporting.m            Size:0 KB
    <https://file.savannah.gnu.org/file/tst_err_reporting.m?file_id=52677>



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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