diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-09-16 18:54:57 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-09-16 18:54:57 -0700 |
commit | 309aab3af38b00c733d3e986808e79b53ffc4bab (patch) | |
tree | e526353108ba6308e868741dd3553ad52b8c4bf0 /scope.h | |
parent | c22c99bc35171a7072ba6278b8a0fdbbaa86236a (diff) | |
download | perl-309aab3af38b00c733d3e986808e79b53ffc4bab.tar.gz |
Make goto &CORE::sub use the right lexical scope
Since goto &foo is supposed to replace the current sub call, as though
foo had been called instead, logically foo should see the same lexical
hints that would have been seen if it had been called to begin with.
Regular Perl subs begin with nextstate ops, so they have their own
lexical scopes, but CORE:: subs see the caller’s PL_curcop. They lack
a nextstate precisely so that they run in the caller’s scope, just as
though a built-in function had been called.
For Perl subs (as opposed to XSUBs), goto-&sub was not reset-
ting PL_curcop to the caller’s value, but leaving as it was, so
goto &CORE::sub would cause the CORE sub to run with the lexical hints
of the subroutine in replaced, instead of that sub’s caller.
This was never a problem until CORE subs came along, as they look like
Perl subs to the internals (they have an op tree and are flagged as
such), but comprise a sequence of ops that can never result from com-
piling Perl source code.
The simple one-line fix is to set PL_curcop in pp_goto for Perl subs
as well as XSUBs. (For XSUBs it is implied by POPBLOCK.)
Diffstat (limited to 'scope.h')
0 files changed, 0 insertions, 0 deletions