summaryrefslogtreecommitdiff
path: root/t/op
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-10-31 21:57:28 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-11-13 04:49:36 -0800
commit04bae31374e4aa02ef4389cc3484ac2558056857 (patch)
treeaf869b37ee042cb56697cf7cecdfb65b1e569221 /t/op
parenta63556160924a497d8ad70cda2f162316ff10cfc (diff)
downloadperl-04bae31374e4aa02ef4389cc3484ac2558056857.tar.gz
Don’t attempt to inline my sub (){$outer_var}
$ perl5.18.2 -Ilib -Mfeature=lexical_subs -e ' my $x; my sub a(){$x}; print a' The lexical_subs feature is experimental at -e line 1. Segmentation fault: 11 Same in blead. When calls to the sub are compiled (the ‘a’ in ‘print a’) the value of the lexical variable cannot possibly known, because the sub hasn’t been cloned yet, and all we have is the closure prototype. A potentially constant closure prototype is marked CvCONST and cv_const_sv_or_av (called by the code in toke.c that handles bare- words) thinks that CvCONST means we have a constant XSUB. Only lexi- cal subs allow a closure prototype to reach that function. We shouldn’t mark the closure prototype as CvCONST to begin with. Because when we do, the ‘constant’ is retrieved from CvXUBANY, which is a union shared by CvSTART. Then toke.c does SvREFCNT_inc on CvSTART, and screws up the op tree.
Diffstat (limited to 't/op')
-rw-r--r--t/op/lexsub.t7
1 files changed, 6 insertions, 1 deletions
diff --git a/t/op/lexsub.t b/t/op/lexsub.t
index 385aaeedd1..e170555517 100644
--- a/t/op/lexsub.t
+++ b/t/op/lexsub.t
@@ -7,7 +7,7 @@ BEGIN {
*bar::is = *is;
*bar::like = *like;
}
-plan 143;
+plan 144;
# -------------------- Errors with feature disabled -------------------- #
@@ -788,6 +788,11 @@ is runperl(switches => ['-lXMfeature=:all'],
print handel,"ok ",curr_test()," - no 'No comma allowed' after my sub\n";
curr_test(curr_test()+1);
}
+{
+ my $x = 43;
+ my sub y :prototype() {$x};
+ is y, 43, 'my sub that looks like constant closure';
+}
# -------------------- Interactions (and misc tests) -------------------- #