From: Rafael Garcia-Suarez Date: Tue, 21 Nov 2006 14:45:19 +0000 (+0000) Subject: Invalidate the method lookup cache when assigning to a glob X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ae6d515f69537dd5e2631b15104c2c90d022fd19;p=p5sagit%2Fp5-mst-13.2.git Invalidate the method lookup cache when assigning to a glob named "isa". (That happens when importing "isa" from UNIVERSAL, for example.) Fixes bug #24824. p4raw-id: //depot/perl@29336 --- diff --git a/pp_hot.c b/pp_hot.c index 9b293de..14bfd2c 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -138,7 +138,7 @@ PP(pp_sassign) assert(SvROK(cv)); } - /* Can do the optimisation if right (LVAUE) is not a typeglob, + /* Can do the optimisation if right (LVALUE) is not a typeglob, left (RVALUE) is a reference to something, and we're in void context. */ if (!got_coderef && gv_type != SVt_PVGV && GIMME_V == G_VOID) { @@ -180,6 +180,10 @@ PP(pp_sassign) LEAVE; } + if (strEQ(GvNAME(right),"isa")) { + GvCVGEN(right) = 0; + ++PL_sub_generation; + } } SvSetMagicSV(right, left); SETs(right); diff --git a/t/op/universal.t b/t/op/universal.t index a41a8ea..5e7fb1e 100755 --- a/t/op/universal.t +++ b/t/op/universal.t @@ -10,7 +10,7 @@ BEGIN { require "./test.pl"; } -plan tests => 109; +plan tests => 110; $a = {}; bless $a, "Bob"; @@ -216,3 +216,10 @@ ok( Bar->DOES( 'Bar' ), '... and should fall back to isa()' ); ok( Bar->DOES( 'Foo' ), '... even when inherited' ); ok( Baz->DOES( 'Baz' ), '... even without inheriting any other DOES()' ); ok( ! Baz->DOES( 'Foo' ), '... returning true or false appropriately' ); + +package Pig; +package Bodine; +Bodine->isa('Pig'); +*isa = \&UNIVERSAL::isa; +eval { isa({}, 'HASH') }; +::is($@, '', "*isa correctly found")