Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 78805
Status: stalled
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: lamoz [...] adriver.ru
Cc:
AdminCc:

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



Subject: Failure while validating read-only against typeconstraint
Hi! The following code breaks for me: <snip> use Moose::Util::TypeConstraints; use Readonly; my $t = subtype as 'Str', where { 1 }; Readonly our $data => 'lala'; map { $t->validate( $_ ) } $data; </snip> The stacktrace is: <snip> Modification of a read-only value attempted at /usr/lib64/perl5/site_perl/5.8.8/Readonly.pm line 75 Readonly::Scalar::__ANON__('Readonly::Scalar=SCALAR(0x1520c70)', undef) called at /home/newuser/perl5/lib/perl5/x86_64-linux-thread- multi/Moose/Meta/TypeConstraint.pm line 395 Moose::Meta::TypeConstraint::__ANON__('lala') called at /home/newuser/perl5/lib/perl5/x86_64-linux-thread-multi/Moose/Meta/TypeConstraint.pm line 195 Moose::Meta::TypeConstraint::validate('Moose::Meta::TypeConstraint=HASH(0x154b500)', 'lala') called at /usr/lib64/perl5/site_perl/5.8.8/Readonly.pm line 75 Readonly::Scalar::__ANON__('Readonly::Scalar=SCALAR(0x1520c70)', undef) called at /home/newuser/perl5/lib/perl5/x86_64-linux-thread- multi/Moose/Meta/TypeConstraint.pm line 395 Moose::Meta::TypeConstraint::__ANON__('lala') called at /home/newuser/perl5/lib/perl5/x86_64-linux-thread-multi/Moose/Meta/TypeConstraint.pm line 195 Moose::Meta::TypeConstraint::validate('Moose::Meta::TypeConstraint=HASH(0x154b500)', 'lala') called at ./test.pl line 10 Modification of a read-only value attempted at /usr/lib64/perl5/site_perl/5.8.8/Readonly.pm line 75 Readonly::Scalar::__ANON__('Readonly::Scalar=SCALAR(0x1520c70)', 'lala') called at /usr/lib64/perl5/site_perl/5.8.8/Readonly.pm line 75 Readonly::Scalar::__ANON__('Readonly::Scalar=SCALAR(0x1520c70)', 'lala') called at /usr/lib64/perl5/5.8.8/Carp.pm line 100 </snip> perl v5.8.8 built for x86_64-linux-thread-multi Moose v2.0603 Readonly v1.03
On Mon Aug 06 01:48:11 2012, lamoz wrote: Show quoted text
> Hi! > > The following code breaks for me: > > <snip> > use Moose::Util::TypeConstraints; > use Readonly; > > my $t = subtype as 'Str', > where { 1 }; > > Readonly our $data => 'lala'; > map { $t->validate( $_ ) } $data; > </snip> > > The stacktrace is: > > <snip> > Modification of a read-only value attempted at > /usr/lib64/perl5/site_perl/5.8.8/Readonly.pm line 75 >
Readonly::Scalar::__ANON__('Readonly::Scalar=SCALAR(0x1520c70)', Show quoted text
> undef) called at /home/newuser/perl5/lib/perl5/x86_64-linux-thread- > multi/Moose/Meta/TypeConstraint.pm line 395 > Moose::Meta::TypeConstraint::__ANON__('lala') called at > /home/newuser/perl5/lib/perl5/x86_64-linux-thread- > multi/Moose/Meta/TypeConstraint.pm line 195 >
Moose::Meta::TypeConstraint::validate('Moose::Meta::TypeConstraint=HASH( 0x154b500)', Show quoted text
> 'lala') called at /usr/lib64/perl5/site_perl/5.8.8/Readonly.pm line 75 >
Readonly::Scalar::__ANON__('Readonly::Scalar=SCALAR(0x1520c70)', Show quoted text
> undef) called at /home/newuser/perl5/lib/perl5/x86_64-linux-thread- > multi/Moose/Meta/TypeConstraint.pm line 395 > Moose::Meta::TypeConstraint::__ANON__('lala') called at > /home/newuser/perl5/lib/perl5/x86_64-linux-thread- > multi/Moose/Meta/TypeConstraint.pm line 195 >
Moose::Meta::TypeConstraint::validate('Moose::Meta::TypeConstraint=HASH( 0x154b500)', Show quoted text
> 'lala') called at ./test.pl line 10 > Modification of a read-only value attempted at > /usr/lib64/perl5/site_perl/5.8.8/Readonly.pm line 75 >
Readonly::Scalar::__ANON__('Readonly::Scalar=SCALAR(0x1520c70)', Show quoted text
> 'lala') called at /usr/lib64/perl5/site_perl/5.8.8/Readonly.pm line 75 >
Readonly::Scalar::__ANON__('Readonly::Scalar=SCALAR(0x1520c70)', Show quoted text
> 'lala') called at /usr/lib64/perl5/5.8.8/Carp.pm line 100 > </snip> > > perl v5.8.8 built for x86_64-linux-thread-multi > Moose v2.0603 > Readonly v1.03
I can reproduce this with 5.10.1 and 5.12.3, but not 5.14.2, so it might be a core bug that's since been fixed. Also, if I remove the map and just call $t->validate($data), it works. I don't know if this is something that we can fix in Moose.
From: lamoz [...] adriver.ru
Show quoted text
> Also, if I remove the map and just call $t->validate($data), it works.
"Modification of a read-only value" happens when read-only is aliased with $_ no matter what construction is used - foreach, grep, map or even 'all' from List::MoreUtils
On Mon Sep 17 02:03:23 2012, lamoz wrote: Show quoted text
> > Also, if I remove the map and just call $t->validate($data), it works.
> > "Modification of a read-only value" happens when read-only is aliased > with $_ no matter what construction is used - foreach, grep, map or even > 'all' from List::MoreUtils
I looked into this and the underlying issue is that Moose::Meta::TypeConstraint has this bit of code: local $_ = $args[0]; If $_ currently contains a Readonly variable, then this ends up calling Readonly->STORE on the variable, which in turn dies. I'm not sure why this works in 5.14 and above. Presumably it has to do with some sort of internals change. We can't remove the "local $_" bit, because the API for type constraints says that $_ will contain the value to be checked when the validation sub is called. I don't think we can fix this, so I'm going to mark this as "stalled".