Mercurial > octave
changeset 30667:f3e5f531e6b2
maint: merge stable to default.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 23 Jan 2022 19:56:13 -0800 |
parents | bf28cc6f2f46 (current diff) 8c6486ffc1d9 (diff) |
children | 965ead41658b |
files | libinterp/corefcn/error.cc |
diffstat | 2 files changed, 22 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/error.cc Sun Jan 23 20:35:47 2022 +0100 +++ b/libinterp/corefcn/error.cc Sun Jan 23 19:56:13 2022 -0800 @@ -380,8 +380,6 @@ Cell& line = retval.contents (2); Cell& column = retval.contents (3); - bool have_column = false; - octave_idx_type k = 0; for (const auto& frm : frames) @@ -389,19 +387,11 @@ file(k) = frm.file_name (); name(k) = frm.fcn_name (); line(k) = frm.line (); - int c = frm.column (); - if (c > 0) - { - have_column = true; - column(k) = c; - } + column(k) = frm.column (); k++; } - if (! have_column) - retval.rmfield ("column"); - return retval; } @@ -413,13 +403,7 @@ Cell file = stack.contents ("file"); Cell name = stack.contents ("name"); Cell line = stack.contents ("line"); - Cell column; - bool have_column = false; - if (stack.contains ("column")) - { - have_column = true; - column = stack.contents ("column"); - } + Cell column = stack.contents ("column"); octave_idx_type nel = name.numel (); @@ -427,8 +411,7 @@ frames.push_back (frame_info (file(i).string_value (), name(i).string_value (), line(i).int_value (), - (have_column - ? column(i).int_value () : -1))); + column(i).int_value ())); return frames; } @@ -619,13 +602,23 @@ execution_exception ee ("error", id, msg, stack_info); - if (! stack.isempty () - && ! (stack.contains ("file") && stack.contains ("name") - && stack.contains ("line"))) - error ("rethrow: STACK struct must contain the fields 'file', 'name', and 'line'"); + if (! stack.isempty ()) + { + if (! (stack.contains ("file") && stack.contains ("name") + && stack.contains ("line"))) + error ("rethrow: STACK struct must contain the fields 'file', 'name', and 'line'"); - if (! stack.isempty ()) - ee.set_stack_info (make_stack_frame_list (stack)); + if (! stack.contains ("column")) + { + octave_map new_stack = stack; + + new_stack.setfield ("column", Cell (octave_value (-1))); + + ee.set_stack_info (make_stack_frame_list (new_stack)); + } + else + ee.set_stack_info (make_stack_frame_list (stack)); + } throw_error (ee); }
--- a/test/error.tst Sun Jan 23 20:35:47 2022 +0100 +++ b/test/error.tst Sun Jan 23 19:56:13 2022 -0800 @@ -123,6 +123,9 @@ %! struct ("file", "foo.m", "name", "foo", "line", 13)); %! rethrow (y); %! catch +%! stk = y.stack; +%! [stk.column] = deal (-1); +%! y.stack = stk; %! assert (y, lasterror ()); %! end_try_catch %! end_try_catch