diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-11-17 08:34:31 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-11-17 09:18:02 -0800 |
commit | 16c632750a8d65ba39bf6c2e2b149e3ffebf467a (patch) | |
tree | cea370764d98d5bc12135180d4750fb2e46c0d78 /proto.h | |
parent | cd6472fc34fd70358c7c0cf2c39a2eb7fe57114d (diff) | |
download | perl-16c632750a8d65ba39bf6c2e2b149e3ffebf467a.tar.gz |
Localise PL_curcop for BEGIN blocks
Usually when a BEGIN block exits it has to set PL_curcop to
&PL_compiling, so that subsequent compiled code in the surrounding
scope will have the right warning hints during compilation.
If an XS function creates a BEGIN block via newXS or newATTRSUB, how-
ever, the assumption that compilation will resume as soon as the block
exits is false.
This can be demonstrated with this code, which warns about CHECK and
INIT blocks created too late when it shouldn’t due to ‘no warnings’:
use warnings;
eval q|
BEGIN{
no warnings;
package XS::APItest; require XSLoader; XSLoader::load()
}
|;
In every case where it is correct for BEGIN to set PL_curcop to
&PL_compiling when it exits it is actually just restoring it to its
previous value, so localisation is the right fix.
Diffstat (limited to 'proto.h')
0 files changed, 0 insertions, 0 deletions