This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix for bug: [perl #32562] __PACKAGE__ symbol has wrong value
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 23 Nov 2004 13:35:34 +0000 (13:35 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 23 Nov 2004 13:35:34 +0000 (13:35 +0000)
after eval or require

p4raw-id: //depot/perl@23528

t/comp/package.t
toke.c

index 6781be4..d63e108 100755 (executable)
@@ -1,6 +1,6 @@
 #!./perl
 
 #!./perl
 
-print "1..12\n";
+print "1..14\n";
 
 $blurfl = 123;
 $foo = 3;
 
 $blurfl = 123;
 $foo = 3;
@@ -67,4 +67,7 @@ print "$Q" =~ /^__ANON__=/ ? "ok 11\n" : "not ok 11\n";
 
 print ref $Q eq "__ANON__" ? "ok 12\n" : "not ok 12\n";
 
 
 print ref $Q eq "__ANON__" ? "ok 12\n" : "not ok 12\n";
 
+package bug32562;
 
 
+print       __PACKAGE__  eq 'bug32562' ? "ok 13\n" : "not ok 13\n";
+print eval '__PACKAGE__' eq 'bug32562' ? "ok 14\n" : "not ok 14\n";
diff --git a/toke.c b/toke.c
index a7a9068..d798946 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -4305,7 +4305,7 @@ Perl_yylex(pTHX)
        case KEY___PACKAGE__:
            yylval.opval = (OP*)newSVOP(OP_CONST, 0,
                                        (PL_curstash
        case KEY___PACKAGE__:
            yylval.opval = (OP*)newSVOP(OP_CONST, 0,
                                        (PL_curstash
-                                        ? newSVsv(PL_curstname)
+                                        ? newSVpv(HvNAME(PL_curstash), 0)
                                         : &PL_sv_undef));
            TERM(THING);
 
                                         : &PL_sv_undef));
            TERM(THING);