From: Rafael Garcia-Suarez Date: Mon, 16 Jan 2006 19:16:58 +0000 (+0000) Subject: defined %foo::bar:: wasn't working like it used to do in evals X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d6069db2e52f58ef65bf59f2fd453604270d2205;p=p5sagit%2Fp5-mst-13.2.git defined %foo::bar:: wasn't working like it used to do in evals (and, consequently, when require'ing modules.) p4raw-id: //depot/perl@26867 --- diff --git a/t/op/stash.t b/t/op/stash.t index 4a3cf06..53abbdd 100644 --- a/t/op/stash.t +++ b/t/op/stash.t @@ -7,7 +7,7 @@ BEGIN { require "./test.pl"; -plan( tests => 11 ); +plan( tests => 13 ); # Used to segfault (bug #15479) fresh_perl_is( @@ -51,6 +51,11 @@ package main; ); } +# now tests in eval + +ok( !eval { defined %achtfaden:: }, 'works in eval{}' ); +ok( !eval q{ defined %schoenmaker:: }, 'works in eval("")' ); + # now tests with strictures use strict; diff --git a/toke.c b/toke.c index efa9e42..6f27031 100644 --- a/toke.c +++ b/toke.c @@ -5807,21 +5807,21 @@ S_pending_ident(pTHX) yylval.opval->op_private = OPpCONST_ENTERED; gv_fetchpv( PL_tokenbuf+1, - PL_in_eval - ? (GV_ADDMULTI | GV_ADDINEVAL) - /* If the identifier refers to a stash, don't autovivify it. - * Change 24660 had the side effect of causing symbol table - * hashes to always be defined, even if they were freshly - * created and the only reference in the entire program was - * the single statement with the defined %foo::bar:: test. - * It appears that all code in the wild doing this actually - * wants to know whether sub-packages have been loaded, so - * by avoiding auto-vivifying symbol tables, we ensure that - * defined %foo::bar:: continues to be false, and the existing - * tests still give the expected answers, even though what - * they're actually testing has now changed subtly. - */ - : !(*PL_tokenbuf == '%' && *(d = PL_tokenbuf + strlen(PL_tokenbuf) - 1) == ':' && d[-1] == ':'), + /* If the identifier refers to a stash, don't autovivify it. + * Change 24660 had the side effect of causing symbol table + * hashes to always be defined, even if they were freshly + * created and the only reference in the entire program was + * the single statement with the defined %foo::bar:: test. + * It appears that all code in the wild doing this actually + * wants to know whether sub-packages have been loaded, so + * by avoiding auto-vivifying symbol tables, we ensure that + * defined %foo::bar:: continues to be false, and the existing + * tests still give the expected answers, even though what + * they're actually testing has now changed subtly. + */ + (*PL_tokenbuf == '%' && *(d = PL_tokenbuf + strlen(PL_tokenbuf) - 1) == ':' && d[-1] == ':' + ? 0 + : PL_in_eval ? (GV_ADDMULTI | GV_ADDINEVAL) : GV_ADD), ((PL_tokenbuf[0] == '$') ? SVt_PV : (PL_tokenbuf[0] == '@') ? SVt_PVAV : SVt_PVHV));