Commit | Line | Data |
cca8f13b |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | if( $ENV{PERL_CORE} ) { |
5 | chdir 't' if -d 't'; |
6 | @INC = '../lib'; |
7 | } |
8 | } |
9 | |
10 | use SelfLoader; |
4e3c68f2 |
11 | print "1..1\n"; |
cca8f13b |
12 | |
13 | # this script checks that errors on self-loaded |
14 | # subroutines that affect $@ are reported |
15 | |
16 | eval { buggy(); }; |
17 | unless ($@ =~ /^syntax error/) { |
18 | print "not "; |
19 | } |
20 | print "ok 1 - syntax errors are reported\n"; |
21 | |
22 | __END__ |
23 | |
24 | sub buggy |
25 | { |
26 | +>*; |
27 | } |
28 | |
29 | |
30 | =head1 RT 40216 |
31 | |
32 | by Bo Lindbergh <blgl@hagernas.com>, at Aug 22, 2006 5:42 PM |
33 | |
34 | In the example below, there's a syntax error in the selfloaded |
35 | code for main::buggy. When the eval fails, SelfLoader::AUTOLOAD |
36 | tries to report this with "croak $@;". Unfortunately, |
37 | SelfLoader::croak does "require Carp;" without protecting $@, |
38 | which gets clobbered. The program then dies with the |
39 | uninformative message " at ./example line 3". |
40 | |
41 | #! /usr/local/bin/perl |
42 | use SelfLoader; |
43 | buggy(); |
44 | __END__ |
45 | sub buggy |
46 | { |
47 | +>*; |
48 | } |
49 | |
50 | =cut |
51 | |