From: Rafael Garcia-Suarez Date: Thu, 15 Dec 2005 17:12:01 +0000 (+0000) Subject: Don't autovivify stashes as soon as the lexer sees them. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=adc51b978ed1b2e9d4512c9bfa80386ac917d05a;p=p5sagit%2Fp5-mst-13.2.git Don't autovivify stashes as soon as the lexer sees them. This makes defined %foo::bar:: work again. Add tests for it, remove note in perldelta about having broken it. p4raw-id: //depot/perl@26370 --- diff --git a/pod/perl593delta.pod b/pod/perl593delta.pod index 1c0a8fb..9ebc819 100644 --- a/pod/perl593delta.pod +++ b/pod/perl593delta.pod @@ -15,16 +15,6 @@ L for the differences between 5.8.0 and 5.9.2. C<_> is now forced to be a bareword after a filetest operator. This solves a number of misparsing issues when a global C<_> subroutine is defined. -=head2 C - -This used to report whether the C package was created. Now it's -always true, as a side-effect of a change to shrink the internal size of -hash structures. Note that using C on hashes was deprecated -anyway. To achieve the same result, you can use a symbolic reference -instead (and this is backwards-compatible): - - defined %{"foo::bar::"} - =head1 Core Enhancements =head1 Modules and Pragmata diff --git a/t/op/stash.t b/t/op/stash.t index 0cd7ebf..7441775 100644 --- a/t/op/stash.t +++ b/t/op/stash.t @@ -7,7 +7,7 @@ BEGIN { require "./test.pl"; -plan( tests => 2 ); +plan( tests => 8 ); # Used to segfault (bug #15479) fresh_perl_is( @@ -24,3 +24,15 @@ fresh_perl_is( { switches => [ '-w' ] }, q(Insert a non-GV in a stash, under warnings 'once'), ); + +ok( !defined %oedipa::maas::, q(stashes aren't defined if not used) ); +ok( !defined %{"oedipa::maas::"}, q(- work with hard refs too) ); + +ok( defined %tyrone::slothrop::, q(stashes are defined if seen at compile time) ); +ok( defined %{"tyrone::slothrop::"}, q(- work with hard refs too) ); + +ok( defined %bongo::shaftsbury::, q(stashes are defined if a var is seen at compile time) ); +ok( defined %{"bongo::shaftsbury::"}, q(- work with hard refs too) ); + +package tyrone::slothrop; +$bongo::shaftsbury::scalar = 1; diff --git a/toke.c b/toke.c index 5a0a5b3..eed7030 100644 --- a/toke.c +++ b/toke.c @@ -5661,10 +5661,15 @@ S_pending_ident(pTHX) /* build ops for a bareword */ yylval.opval = (OP*)newSVOP(OP_CONST, 0, newSVpv(PL_tokenbuf+1, 0)); yylval.opval->op_private = OPpCONST_ENTERED; - gv_fetchpv(PL_tokenbuf+1, PL_in_eval ? (GV_ADDMULTI | GV_ADDINEVAL) : TRUE, - ((PL_tokenbuf[0] == '$') ? SVt_PV - : (PL_tokenbuf[0] == '@') ? SVt_PVAV - : SVt_PVHV)); + gv_fetchpv( + PL_tokenbuf+1, + PL_in_eval + ? (GV_ADDMULTI | GV_ADDINEVAL) + /* if the identifier refers to a stash, don't autovivify it */ + : !(*PL_tokenbuf == '%' && *(d = PL_tokenbuf + strlen(PL_tokenbuf) - 1) == ':' && d[-1] == ':'), + ((PL_tokenbuf[0] == '$') ? SVt_PV + : (PL_tokenbuf[0] == '@') ? SVt_PVAV + : SVt_PVHV)); return WORD; }