diff --git a/libinterp/corefcn/call-stack.cc b/libinterp/corefcn/call-stack.cc --- a/libinterp/corefcn/call-stack.cc +++ b/libinterp/corefcn/call-stack.cc @@ -1104,11 +1104,6 @@ namespace octave return octave_value (); } - void call_stack::clear_current_frame_values (void) - { - m_cs[m_curr_frame]->clear_values (); - } - void call_stack::display (void) const { std::ostream& os = octave_stdout; diff --git a/libinterp/corefcn/call-stack.h b/libinterp/corefcn/call-stack.h --- a/libinterp/corefcn/call-stack.h +++ b/libinterp/corefcn/call-stack.h @@ -293,8 +293,6 @@ namespace octave bool have_regexp, bool return_list, bool verbose, const std::string& msg = ""); - void clear_current_frame_values (void); - void display (void) const; void set_auto_fcn_var (stack_frame::auto_var_type avt, diff --git a/libinterp/corefcn/stack-frame.cc b/libinterp/corefcn/stack-frame.cc --- a/libinterp/corefcn/stack-frame.cc +++ b/libinterp/corefcn/stack-frame.cc @@ -1074,10 +1074,10 @@ namespace octave return new scope_stack_frame (tw, scope, index, parent_link, static_link); } - // This function is only implemented for user_fcn stack frames and - // only called for those objects using unwind_protect and the - // call_stack::clear_current_frame_values function. Anything else - // indicates an error in the implementation. + // This function is only implemented and should only be called for + // user_fcn stack frames. Anything else indicates an error in the + // implementation. OTOH, we could make it do nothing or possibly + // issue a warning if it is called in other cases? void stack_frame::clear_values (void) { diff --git a/libinterp/parse-tree/pt-eval.cc b/libinterp/parse-tree/pt-eval.cc --- a/libinterp/parse-tree/pt-eval.cc +++ b/libinterp/parse-tree/pt-eval.cc @@ -2740,9 +2740,10 @@ namespace octave unwind_protect_var upv (m_statement_context, SC_FUNCTION); - unwind_action act1 ([this] () { - m_call_stack.clear_current_frame_values (); - }); + unwind_action act1 ([] (std::shared_ptr frm) + { + frm->clear_values (); + }, m_call_stack.get_current_stack_frame ()); { profiler::enter block (m_profiler, user_function);