Some simplification of the inlined type check
[gitmo/Mouse.git] / lib / Mouse / Meta / Attribute.pm
index 4bdb9f8..ef50e05 100644 (file)
@@ -84,10 +84,10 @@ sub generate_accessor {
         }
 
             if ($constraint) {
-                $accessor .= 'do {
-                    my $display = defined($_) ? overload::StrVal($_) : "undef";
-                    Carp::confess("Attribute ($name) does not pass the type constraint because: Validation failed for \'$type\' failed with value $display") unless $constraint->();
-                };'
+                $accessor .= 'unless ($constraint->()) {
+                        my $display = defined($_) ? overload::StrVal($_) : "undef";
+                        Carp::confess("Attribute ($name) does not pass the type constraint because: Validation failed for \'$type\' failed with value $display");
+                }'
             }
 
             $accessor .= '$self->{$key} = $_;';