Permalink
Browse files

Fix for RT#61726

  • Loading branch information...
1 parent ce4fe7b commit cff879223b92fecda1d3f456a224c4adf709e19c @Leont committed Oct 2, 2010
Showing with 10 additions and 3 deletions.
  1. +2 −2 lib/Const/Fast.pm
  2. +8 −1 t/10-basics.t
View
4 lib/Const/Fast.pm
@@ -4,7 +4,7 @@ use 5.008;
use strict;
use warnings FATAL => 'all';
-use Scalar::Util qw/reftype/;
+use Scalar::Util qw/reftype blessed/;
use Carp qw/croak/;
use Sub::Exporter -setup => { exports => [qw/const/], groups => { default => [qw/const/] } };
@@ -15,7 +15,7 @@ our $VERSION = '0.005';
sub _make_readonly {
my (undef, $dont_clone) = @_;
- if (my $reftype = reftype $_[0] and not &Internals::SvREADONLY($_[0])) {
+ if (my $reftype = reftype $_[0] and not blessed($_[0]) and not &Internals::SvREADONLY($_[0])) {
my $needs_cloning = !$dont_clone && &Internals::SvREFCNT($_[0]) > 1;
&Internals::SvREADONLY($_[0], 1);
if ($reftype eq 'ARRAY') {
View
9 t/10-basics.t
@@ -4,7 +4,7 @@
use strict;
use warnings FATAL => 'all';
-use Test::More tests => 15;
+use Test::More tests => 17;
use Test::Exception;
use Const::Fast;
@@ -63,3 +63,10 @@ ok eq_array(\@array, [qw[an array value]]) => 'const reassign no effect';
throws_reassign { const %hash => "another", "hash" } 'Hash reassign die';
ok eq_hash(\%hash, {a => 'hash', of => 'things'}) => 'Const reassign no effect';
+# Test for RT#61726
+const my $rx => qr/foo/;
+isa_ok $rx, 'Regexp';
+
+const my %rx => ( foo => qr/foo/ );
+isa_ok $rx{foo}, 'Regexp' or diag( Dumper( \%rx ) ); # fails
+

0 comments on commit cff8792

Please sign in to comment.