From: Nicholas Clark Date: Thu, 27 Dec 2007 21:41:03 +0000 (+0000) Subject: scalars used in postponed subexpressions aren't first class regexps, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a2794585f298613c6353549c1058857370acfed3;p=p5sagit%2Fp5-mst-13.2.git scalars used in postponed subexpressions aren't first class regexps, so don't upgrade them to ORANGE before attaching qr magic. (And don't stop using qr magic once regexps become first class) p4raw-id: //depot/perl@32748 --- diff --git a/regexec.c b/regexec.c index f932d17..be159ed 100644 --- a/regexec.c +++ b/regexec.c @@ -3741,7 +3741,9 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) if (!(SvFLAGS(ret) & (SVs_TEMP | SVs_PADTMP | SVf_READONLY | SVs_GMG))) { - SvUPGRADE(ret, SVt_ORANGE); + /* This isn't a first class regexp. Instead, it's + caching a regexp onto an existing, Perl visible + scalar. */ sv_magic(ret,(SV*)ReREFCNT_inc(re), PERL_MAGIC_qr,0,0); } diff --git a/t/op/pat.t b/t/op/pat.t index 61ac3f3..138e5b1 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -4512,6 +4512,12 @@ sub kt } } +{ + my $a = 3; "" =~ /(??{ $a })/; + my $b = $a; + iseq($b, $a, "copy of scalar used for postponed subexpression"); +} + # Test counter is at bottom of file. Put new tests above here. #------------------------------------------------------------------- # Keep the following tests last -- they may crash perl @@ -4570,6 +4576,6 @@ ok($@=~/\QSequence \k... not terminated in regex;\E/); iseq(0+$::test,$::TestCount,"Got the right number of tests!"); # Don't forget to update this! BEGIN { - $::TestCount = 4013; + $::TestCount = 4014; print "1..$::TestCount\n"; }