This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #78634] Conflict in defining constant INIT
authorFather Chrysostomos <sprout@cpan.org>
Fri, 26 Nov 2010 15:22:47 +0000 (07:22 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 26 Nov 2010 17:39:51 +0000 (09:39 -0800)
commit75bd28cfd597653e1169cbeb4920b7ba42eb8503
tree4ce63bcfc2b1cb321bf8127b0e8293eded8bb985
parentabf9167d3fff002ddaed53abb44d638387bca978
[perl #78634] Conflict in defining constant INIT

When gv_init tries to turn a constant named INIT into a CV, the auto-
matic special processing of the INIT ‘block’ kicks in, which removes
the CV from the GV.

This should not happen with gv_init, as $::{INIT} = \5 is supposed
to be equivalent to *INIT = sub(){5}, which does not do that.

This commit makes gv_init check for that, increase the reference
count, and reassign the CV. It does not stop the CV from being called
as a special block, but it is harmless to call a constant CV.
gv.c
t/op/blocks.t