=== modified file 'lib/Struct/Dumb.pm'
--- lib/Struct/Dumb.pm 2015-09-30 17:31:56 +0000
+++ lib/Struct/Dumb.pm 2015-10-06 21:24:25 +0000
@@ -152,6 +152,7 @@
my %subs;
foreach ( 0 .. $#$fields ) {
my $idx = $_;
+ no overloading;
$subs{$fields->[$idx]} = $lvalue ? sub :lvalue { shift->[$idx] }
: sub { shift->[$idx] };
}
@@ -192,6 +193,11 @@
if( my $predicate = $opts{predicate} ) {
*{"${caller}::$predicate"} = sub { ( ref($_[0]) // "" ) eq $pkg };
}
+
+ require overload;
+ $pkg->overload::OVERLOAD(
+ '@{}' => sub { croak "Cannot use $pkg as an ARRAY reference" },
+ );
}
=head2 struct
=== modified file 't/01point.t'
--- t/01point.t 2014-07-24 08:49:50 +0000
+++ t/01point.t 2015-10-06 21:24:25 +0000
@@ -28,4 +28,8 @@
qr/^usage: main::Point\(\$x, \$y\) at \S+ line \d+\.?\n/,
'Point(30) throws usage exception' );
+like( exception { @{ Point(0, 0) } },
+ qr/^Cannot use main::Point as an ARRAY reference at \S+ line \d+\.?\n/,
+ 'Array deref throws exception' );
+
done_testing;