From: Dave Rolsky Date: Sat, 18 Feb 2012 16:55:32 +0000 (-0600) Subject: Fix implementation of _STRINGLIKE0 X-Git-Tag: 2.0500~93 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dcba17d107994b1899c36dd92b1e7b7c93a8f86a;p=gitmo%2FMoose.git Fix implementation of _STRINGLIKE0 This was checking for string overloading but only considered that valid if it returned a non-zero length string, even though for plain old strings, an empty string was accepted. In practice, this didn't matter, because if this check failed, it would just check to see if "$_[0] eq q{}", which stringified the object. --- diff --git a/lib/Moose/Util.pm b/lib/Moose/Util.pm index 8b4c34f..09803d4 100644 --- a/lib/Moose/Util.pm +++ b/lib/Moose/Util.pm @@ -308,12 +308,14 @@ sub meta_class_alias { # XXX - this should be added to Params::Util sub _STRINGLIKE0 ($) { - return _STRING( $_[0] ) - || ( defined $_[0] - && $_[0] eq q{} ) - || ( blessed $_[0] - && overload::Method( $_[0], q{""} ) - && length "$_[0]" ); + return 1 if _STRING( $_[0] ); + if ( blessed $_[0] ) { + return overload::Method( $_[0], q{""} ); + } + + return 1 if defined $_[0] && $_[0] eq q{}; + + return 0; } sub _reconcile_roles_for_metaclass {