Merge branch 'topic/cmop-merge'
[gitmo/Moose.git] / lib / Moose / Util / TypeConstraints / OptimizedConstraints.pm
index 6b83595..23a7deb 100644 (file)
@@ -11,11 +11,12 @@ sub Value { defined($_[0]) && !ref($_[0]) }
 
 sub Ref { ref($_[0]) }
 
-# We need to use a temporary here to flatten LVALUEs, for instance as in
+# We might need to use a temporary here to flatten LVALUEs, for instance as in
 # Str(substr($_,0,255)).
 sub Str {
-    my $value = $_[0];
-    defined($value) && ref(\$value) eq 'SCALAR'
+    defined($_[0])
+      && (   ref(\             $_[0] ) eq 'SCALAR'
+          || ref(\(my $value = $_[0])) eq 'SCALAR')
 }
 
 sub Num { !ref($_[0]) && looks_like_number($_[0]) }