poor line numbering in error messages when using unwind_protect
John W. Eaton
jwe at octave.org
Wed Feb 4 12:35:05 CST 2009
On 1-Feb-2009, Søren Hauberg wrote:
| Hi
|
| Consider the following function (also attached)
|
| function badlinenumber ()
| unwind_protect
| error ("this raises and error at line 3");
| unwind_protect_cleanup
| end_unwind_protect
| endfunction
|
| When I run it I get the following error message
|
| error: this raises and error at line 3
| error: called from:
| error: /home/sh/Skrivebord/badlinenumber.m at line 2, column 3
|
| I would expect the last line to say "line 3, ..." instead of "line
| 2, ...".
|
| I see something similar with try-catch statements. Consider (also
| attached)
|
| function badlinenumber2 ()
| try
| error ("this raises and error at line 3");
| catch
| disp (lasterror ()(1).stack.line);
| end_try_catch
| endfunction
|
| When I call this function I get '2' where I would expect '3'.
|
| Now that I'm testing this I see the same issue with 'for' loops,
|
| function badlinenumber3 ()
| for k = 1:10
| error ("this raises and error at line 3");
| endfor
| endfunction
|
| which once again gives me an error at line 2 instead of 3.
I checked in the following changeset, which seems to fix the problem
for me.
http://hg.savannah.gnu.org/hgweb/octave/rev/33783e94fb16
Thanks,
jwe
More information about the Bug-octave
mailing list