Integrate change #10394 from maintperl; lexical file scope leakage.
Jarkko Hietaniemi [Sun, 3 Jun 2001 14:59:41 +0000 (14:59 +0000)]
p4raw-link: @10394 on //depot/maint-5.6/perl: f8a08f7b8bd67b287f13d07e110e93e62aebd509

p4raw-id: //depot/perl@10395
p4raw-integrated: from //depot/maint-5.6/perl@10393 'copy in'
t/pragma/warn/universal (@5902..) 'merge in' perly.c (@8159..)
vms/perly_c.vms (@8169..) t/op/misc.t (@8636..) perly.y
(@9292..)

perly.c
perly.y
t/op/misc.t
t/pragma/warn/universal
vms/perly_c.vms

diff --git a/perly.c b/perly.c
index 35f64e9..2c63b52 100644 (file)
--- a/perly.c
+++ b/perly.c
@@ -1570,12 +1570,12 @@ case 1:
 #if defined(YYDEBUG) && defined(DEBUGGING)
                    yydebug = (DEBUG_p_TEST);
 #endif
-                   PL_expect = XSTATE;
+                   PL_expect = XSTATE; yyval.ival = block_start(TRUE);
                }
 break;
 case 2:
 #line 135 "perly.y"
-{ newPROG(yyvsp[0].opval); }
+{ newPROG(block_end(yyvsp[-1].ival,yyvsp[0].opval)); }
 break;
 case 3:
 #line 139 "perly.y"
diff --git a/perly.y b/perly.y
index a30f4ce..c682c9c 100644 (file)
--- a/perly.y
+++ b/perly.y
@@ -129,10 +129,10 @@ prog      :       /* NULL */
 #if defined(YYDEBUG) && defined(DEBUGGING)
                    yydebug = (DEBUG_p_TEST);
 #endif
-                   PL_expect = XSTATE;
+                   PL_expect = XSTATE; $$ = block_start(TRUE);
                }
        /*CONTINUED*/   lineseq
-                       { newPROG($2); }
+                       { newPROG(block_end($1,$2)); }
        ;
 
 block  :       '{' remember lineseq '}'
index 90df19a..4b4d803 100755 (executable)
@@ -575,6 +575,18 @@ print qw(ab a\b a\\b);
 EXPECT
 aba\ba\b
 ########
+# lexicals declared after the myeval() definition should not be visible
+# within it
+sub myeval { eval $_[0] }
+my $foo = "ok 2\n";
+myeval('sub foo { local $foo = "ok 1\n"; print $foo; }');
+die $@ if $@;
+foo();
+print $foo;
+EXPECT
+ok 1
+ok 2
+########
 # This test is here instead of pragma/locale.t because
 # the bug depends on in the internal state of the locale
 # settings and pragma/locale messes up that state pretty badly.
index 6dbb1be..d9b1883 100644 (file)
@@ -12,5 +12,3 @@ my $a = bless [] ;
 UNIVERSAL::isa $a, Jim ;
 EXPECT
 Can't locate package Joe for @main::ISA at - line 5.
-Can't locate package Joe for @main::ISA.
-Can't locate package Joe for @main::ISA.
index b515dd1..7d071a0 100644 (file)
@@ -1572,12 +1572,12 @@ case 1:
 #if defined(YYDEBUG) && defined(DEBUGGING)
                    yydebug = (DEBUG_p_TEST);
 #endif
-                   PL_expect = XSTATE;
+                   PL_expect = XSTATE; yyval.ival = block_start(TRUE);
                }
 break;
 case 2:
 #line 135 "perly.y"
-{ newPROG(yyvsp[0].opval); }
+{ newPROG(block_end(yyvsp[-1].ival,yyvsp[0].opval)); }
 break;
 case 3:
 #line 139 "perly.y"