From: Richard Clamp Date: Mon, 28 Jan 2002 02:17:55 +0000 (+0000) Subject: Re: [PATCH] Attribute::Handlers lexical refcount skew (was Re: lexical with attribute... X-Git-Tag: accepted/trunk/20130322.191538~28217 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24952a9cd4e494b52de4ce12a5bb503bc5f60125;p=platform%2Fupstream%2Fperl.git Re: [PATCH] Attribute::Handlers lexical refcount skew (was Re: lexical with attribute, refcount high) Message-ID: <20020128021755.GA28344@mirth.demon.co.uk> p4raw-id: //depot/perl@14488 --- diff --git a/lib/Attribute/Handlers.pm b/lib/Attribute/Handlers.pm index d4cbfff..78acbdb 100644 --- a/lib/Attribute/Handlers.pm +++ b/lib/Attribute/Handlers.pm @@ -145,11 +145,18 @@ sub _gen_handler_AH_() { _apply_handler_AH_($decl,$gphase) if $global_phases{$gphase} <= $global_phase; } - # if _gen_handler_AH_ is being called after CHECK it's - # for a lexical, so we don't want to keep a reference - # around - push @declarations, $decl - if $global_phase == 0; + if ($global_phase != 0) { + # if _gen_handler_AH_ is being called after + # CHECK it's for a lexical, so make sure + # it didn't want to run anything later + + local $Carp::CarpLevel = 2; + carp "Won't be able to apply END handler" + if $phase{$handler}{END}; + } + else { + push @declarations, $decl + } } $_ = undef; } @@ -805,6 +812,12 @@ Something is rotten in the state of the program. An attributed subroutine ceased to exist between the point it was declared and the point at which its attribute handler(s) would have been called. +=item C + +You have defined an END handler for an attribute that is being applied +to a lexical variable. Since the variable may not be available during END +this won't happen. + =back =head1 AUTHOR diff --git a/lib/Attribute/Handlers/t/multi.t b/lib/Attribute/Handlers/t/multi.t index c327b39..7bcb284 100644 --- a/lib/Attribute/Handlers/t/multi.t +++ b/lib/Attribute/Handlers/t/multi.t @@ -165,3 +165,11 @@ sub dummy_our { our $banjo : Dummy; } $applied = 0; dummy_our(); dummy_our(); ok( $applied == 0, 51 ); + +sub UNIVERSAL::Stooge :ATTR(END) {}; +eval { + local $SIG{__WARN__} = sub { die @_ }; + my $groucho : Stooge; +}; +my $match = $@ =~ /^Won't be able to apply END handler/; +ok( $match, 52 );