[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #41651] Nested uses of evalin( 'caller', ... )
From: |
Michael C. Grant |
Subject: |
[Octave-bug-tracker] [bug #41651] Nested uses of evalin( 'caller', ... ) |
Date: |
Fri, 21 Feb 2014 13:59:58 +0000 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/7.0.1 Safari/537.73.11 |
Follow-up Comment #3, bug #41651 (project octave):
I believe I have identified the problem: line 472 of
libinterp/corefcn/toplev.cc, in the function
"octave_call_stack::do_goto_caller_frame":
if (frame == 0 || (f && f->is_user_code ()))
The "frame == 0" test is an attempt to acknowledge that the top-level frame is
equivalent to user code in a function. So far, so good.
But now consider what happens if someone performs an evalin('caller') in a
function called from the command line. It will create a new call_stack_elt
element with the same *scope* and *context* as the command line, and with
elt.fcn==0 because there is no calling function; but it will not be at the top
of the stack, so frame!=0.
Therefore, this test will fail if evalin('caller') is called again, and this
frame will not be treated as user code, as it should.
The corrected code, in my view, should be this:
if (frame == 0 || elt.scope == cs[0].scope || (f && f->is_user_code ()))
or perhaps even more simply,
if (elt.scope == cs[0].scope || (f && f->is_user_code ()))
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?41651>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/