From: chansen Date: Fri, 16 Oct 2009 16:34:55 +0000 (+0200) Subject: Str constraint shouldn't accept GV's X-Git-Tag: 0.93~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9a2215235b9f1438ae908e2515dd2f8141fcabb5;p=gitmo%2FMoose.git Str constraint shouldn't accept GV's --- diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index 12d825f..377772e 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -662,7 +662,7 @@ subtype 'Value' => as 'Defined' => where { !ref($_) } => subtype 'Ref' => as 'Defined' => where { ref($_) } => optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Ref; -subtype 'Str' => as 'Value' => where {1} => +subtype 'Str' => as 'Value' => where { ref(\$_) eq 'SCALAR' } => optimize_as \&Moose::Util::TypeConstraints::OptimizedConstraints::Str; subtype 'Num' => as 'Str' => diff --git a/lib/Moose/Util/TypeConstraints/OptimizedConstraints.pm b/lib/Moose/Util/TypeConstraints/OptimizedConstraints.pm index 1b71222..d6fe17e 100644 --- a/lib/Moose/Util/TypeConstraints/OptimizedConstraints.pm +++ b/lib/Moose/Util/TypeConstraints/OptimizedConstraints.pm @@ -14,7 +14,7 @@ sub Value { defined($_[0]) && !ref($_[0]) } sub Ref { ref($_[0]) } -sub Str { defined($_[0]) && !ref($_[0]) } +sub Str { defined($_[0]) && ref(\$_[0]) eq 'SCALAR' } sub Num { !ref($_[0]) && looks_like_number($_[0]) }