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