summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRichard Clamp <richardc@unixbeard.net>2002-01-28 02:17:55 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-01-29 16:38:58 +0000
commit24952a9cd4e494b52de4ce12a5bb503bc5f60125 (patch)
tree4be4906b8b0f23d56d2dfe21d8932c1bcbdf99cf /lib
parent10b9e8260c4c1410f5b8643f1a9b997c04b2e461 (diff)
downloadperl-24952a9cd4e494b52de4ce12a5bb503bc5f60125.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/Attribute/Handlers.pm23
-rw-r--r--lib/Attribute/Handlers/t/multi.t8
2 files changed, 26 insertions, 5 deletions
diff --git a/lib/Attribute/Handlers.pm b/lib/Attribute/Handlers.pm
index d4cbfffc25..78acbdb8f7 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<Won't be able to apply END handler>
+
+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 c327b390d5..7bcb284a23 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 );