Skip to content

Commit

Permalink
fixed a bizarre error hiding condition
Browse files Browse the repository at this point in the history
turned out to be necessary to localize $@ in Parser::split_proto()
also finally came up with a test case which demonstrates the error
  • Loading branch information
barefootcoder committed Apr 15, 2011
1 parent 8b370c5 commit e0cd9bc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Method/Signatures/Parser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ sub split_proto {
my $proto = shift;
return unless $proto =~ /\S/;

local $@ = undef;

require PPI;
my $ppi = PPI::Document->new(\$proto);
$ppi->prune('PPI::Token::Comment');
Expand Down
14 changes: 14 additions & 0 deletions t/error_interruption.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

use strict;
use warnings;

use lib 't/lib';

use Test::More;
use Test::Exception;


throws_ok { require BarfyDie } qr/requires explicit package name/, "MS doesn't interrupt real compilation error";


done_testing();
25 changes: 25 additions & 0 deletions t/lib/BarfyDie.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# For use with t/error_interruption.t

package BarfyDie;

use strict;
use warnings;

use Method::Signatures;


# This _should_ produce a simple error like the following:
# Global symbol "$foo" requires explicit package name at t/lib/BarfyDie.pm line 13.
$foo = 'hi!';

# And, without the signature below, it would.
# For that matter, if you compile this by itself, it still does.
# However, when you require this file from inside an eval, Method::Signature's parser() method will
# eat the error unless we localize $@ there. So this verifies that we're doing that.

method foo (Str $bar)
{
}


1;

0 comments on commit e0cd9bc

Please sign in to comment.