From: gfx Date: Mon, 11 Jan 2010 07:46:47 +0000 (+0900) Subject: Add the CAVEATS section for the call_sv() failures X-Git-Tag: 0.47~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=13756394019ebd1535c45fdca817887ce6a0b122;p=gitmo%2FMouse.git Add the CAVEATS section for the call_sv() failures --- diff --git a/caveats/RT69939.t b/caveats/RT69939.t new file mode 100644 index 0000000..d6bb172 --- /dev/null +++ b/caveats/RT69939.t @@ -0,0 +1,31 @@ +#!perl -w +# See the CAVEATS section in Mouse.pm +use strict; +use Test::More; + +{ + package Class; + use Mouse; + + has foo => ( + is => 'rw', + + default => sub{ + # Those eval()s which try to load missing modules in + # compile-time triggers a Perl bug (Ticket #69939). + # This is related not only to Mouse, but also to tie-modules. + + #eval 'use MayNotBeInstalled'; # NG + #eval 'BEGIN{ require MayNotBeInstalled }'; # NG + eval{ eval 'use MayNotBeInstalled' }; # OK + ::pass 'in a default callback'; + }, + ); +} + +pass "class definition has been done"; + +isa_ok(Class->new, 'Class'); + +done_testing; + diff --git a/lib/Mouse.pm b/lib/Mouse.pm index 41f6b0c..279d58c 100644 --- a/lib/Mouse.pm +++ b/lib/Mouse.pm @@ -402,6 +402,21 @@ You may use L to replace the superclass list. Please unimport Mouse (C) so that if someone calls one of the keywords (such as L) it will break loudly instead breaking subtly. +=head1 CAVEATS + +If you use Mouse::XS you might see a silent fatal error when you use +callbacks which include C. This is not +a bug in Mouse. In fact, it is a bug in Perl (RT #69939). + +To work around this problem, surround C with C: + + sub callback { + # eval 'use MayNotBeInstalled'; # NG + eval{ eval 'use MayNotBeInstalled' }; # OK + } + +It seems ridiculous, but it works as you expected. + =head1 SOURCE CODE ACCESS We have a public git repository: