# HG changeset patch # User John W. Eaton # Date 1612406907 18000 # Wed Feb 03 21:48:27 2021 -0500 # Branch stable # Node ID a886c2797f1f9c06ee1b0d749181f45ea2407d09 # Parent 4de13dc0eff2a58bc726381f211fedc2fd751b05 fix lookup of "caller" stack frame (bug #59847) * call-stack.cc (call_stack::goto_caller_frame): Use static_link of current user frame instead of dbup to find caller frame. Don't error if we are already at the top scope, just return the top scope. 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 @@ -618,11 +618,12 @@ namespace octave { size_t start = find_current_user_frame (); - // FIXME: is this supposed to be an error? - if (start == 0) - error ("already at top level"); + std::shared_ptr caller_frame = m_cs[start]->static_link (); - m_curr_frame = dbupdown (start, -1, false); + // Allow evalin ('caller', ...) to work when called from the + // top-level prompt. + + m_curr_frame = caller_frame ? caller_frame->index () : 0; } void call_stack::goto_base_frame (void)