Skip Menu |

This queue is for tickets about the Struct-Dumb CPAN distribution.

Report information
The Basics
Id: 107577
Status: resolved
Priority: 0/
Queue: Struct-Dumb

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.04
Fixed in: 0.05



Subject: AUTOLOADed failure reporting sub isn't :lvalue
$ perl -MStruct::Dumb=struct -E 'struct S => [qw( x y )]; S(1,2)->z = 3' Can't modify non-lvalue subroutine call at -e line 1. $ perl -MStruct::Dumb=struct -E 'struct S => [qw( x y )]; S(1,2)->z' main::S does not have a 'z' field at -e line 1. -- Paul Evans
Fixed -- Paul Evans
Subject: rt107577.patch
=== modified file 'lib/Struct/Dumb.pm' --- lib/Struct/Dumb.pm 2015-10-06 21:24:25 +0000 +++ lib/Struct/Dumb.pm 2015-10-06 21:33:45 +0000 @@ -157,9 +157,10 @@ : sub { shift->[$idx] }; } $subs{DESTROY} = sub {}; - $subs{AUTOLOAD} = sub { + $subs{AUTOLOAD} = sub :lvalue { my ( $field ) = our $AUTOLOAD =~ m/::([^:]+)$/; croak "$pkg does not have a '$field' field"; + my $dummy; ## croak can't be last because it isn't lvalue, so this line is required }; my $constructor; === modified file 't/01point.t' --- t/01point.t 2015-10-06 21:24:25 +0000 +++ t/01point.t 2015-10-06 21:33:45 +0000 @@ -24,6 +24,10 @@ qr/^main::Point does not have a 'z' field at \S+ line \d+\.?\n/, '$point->z throws exception' ); +like( exception { $point->z = 40 }, + qr/^main::Point does not have a 'z' field at \S+ line \d+\.?\n/, + '$point->z :lvalue throws exception' ); + like( exception { Point(30) }, qr/^usage: main::Point\(\$x, \$y\) at \S+ line \d+\.?\n/, 'Point(30) throws usage exception' );
Released in 0.05 -- Paul Evans