diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-06-08 10:00:38 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-06-22 22:41:25 -0700 |
commit | 9c074c9444cd8f58ce65da07bd73d0ab82391093 (patch) | |
tree | 91d1472d3b6ef7c2eec4432034ae37723c45a2e0 | |
parent | 7d9995e9e41db0a4ee2cc9a79342f82f81db1f72 (diff) | |
download | perl-9c074c9444cd8f58ce65da07bd73d0ab82391093.tar.gz |
Make __SUB__ work in special blocks
-rw-r--r-- | op.c | 2 | ||||
-rw-r--r-- | pp.c | 2 | ||||
-rw-r--r-- | t/op/current_sub.t | 12 |
3 files changed, 12 insertions, 4 deletions
@@ -10371,7 +10371,7 @@ Perl_rpeep(pTHX_ register OP *o) case OP_RUNCV: if (!(o->op_private & OPpOFFBYONE) && !CvCLONE(PL_compcv)) { SV *sv; - if (CvUNIQUE(PL_compcv)) sv = &PL_sv_undef; + if (CvEVAL(PL_compcv)) sv = &PL_sv_undef; else { sv = newRV((SV *)PL_compcv); sv_rvweaken(sv); @@ -6028,7 +6028,7 @@ PP(pp_runcv) oldsi->si_cxix = oldcxix; } else cv = find_runcv(NULL); - XPUSHs(CvUNIQUE(cv) ? &PL_sv_undef : sv_2mortal(newRV((SV *)cv))); + XPUSHs(CvEVAL(cv) ? &PL_sv_undef : sv_2mortal(newRV((SV *)cv))); RETURN; } diff --git a/t/op/current_sub.t b/t/op/current_sub.t index 7a00032c46..e72a0c5cde 100644 --- a/t/op/current_sub.t +++ b/t/op/current_sub.t @@ -4,10 +4,9 @@ BEGIN { chdir 't'; @INC = qw(../lib); require './test.pl'; + plan (tests => 13); } -plan tests => 11; - is __SUB__, "__SUB__", '__SUB__ is a bareword outside of use feature'; { @@ -37,3 +36,12 @@ for my $x(1..3) { is $subsubs[0]()(0), 1, '__SUB__ inside closure (1)'; is $subsubs[1]()(0), 2, '__SUB__ inside closure (2)'; is $subsubs[2]()(0), 3, '__SUB__ inside closure (3)'; + +BEGIN { + return "begin 1" if @_; + is CORE::__SUB__->(0), "begin 1", 'in BEGIN block' +} +BEGIN { + return "begin 2" if @_; + is &CORE::__SUB__->(0), "begin 2", 'in BEGIN block via & (unoptimised)' +} |