Integrate change #9605 from maintperl into mainline.
Jarkko Hietaniemi [Sat, 7 Apr 2001 14:48:14 +0000 (14:48 +0000)]
can't optimize away scope entry if tr/// is present

p4raw-link: @9605 on //depot/maint-5.6/perl: c26ea50d9fd947ede98c9a5c8c05ff72fc15deaa

p4raw-id: //depot/perl@9607
p4raw-integrated: from //depot/maint-5.6/perl@9606 'merge in' t/op/tr.t
(@9551..) op.c (@9597..)

op.c
t/op/tr.t

diff --git a/op.c b/op.c
index 59cbfa3..11cd640 100644 (file)
--- a/op.c
+++ b/op.c
@@ -2654,6 +2654,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
     I32 grows = 0;
     register short *tbl;
 
+    PL_hints |= HINT_BLOCK_SCOPE;
     complement = o->op_private & OPpTRANS_COMPLEMENT;
     del                = o->op_private & OPpTRANS_DELETE;
     squash     = o->op_private & OPpTRANS_SQUASH;
index 90b0370..7c73430 100755 (executable)
--- a/t/op/tr.t
+++ b/t/op/tr.t
@@ -5,7 +5,7 @@ BEGIN {
     @INC = '../lib';
 }
 
-print "1..67\n";
+print "1..69\n";
 
 $_ = "abcdefghijklmnopqrstuvwxyz";
 
@@ -376,3 +376,12 @@ print "ok 66\n";
 print "not " if hex($a) != 1;
 print "ok 67\n";
 
+# From Inaba Hiroto
+@a = (1,2); map { y/1/./ for $_ } @a;
+print "not " if "@a" ne ". 2";
+print "ok 68\n";
+
+@a = (1,2); map { y/1/./ for $_.'' } @a;
+print "not " if "@a" ne "1 2";
+print "ok 69\n";
+