This makes defined %foo::bar:: work again.
Add tests for it, remove note in perldelta about having broken it.
p4raw-id: //depot/perl@26370
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<defined %foo::bar::>
-
-This used to report whether the C<foo::bar> 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<defined> 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
require "./test.pl";
-plan( tests => 2 );
+plan( tests => 8 );
# Used to segfault (bug #15479)
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;
/* 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;
}