develooper Front page | perl.perl5.porters | Postings from September 2010

Re: [perl #77084] scalar //g match on overloaded object causesstring corruption

Thread Previous | Thread Next
Dave Mitchell
September 1, 2010 09:16
Re: [perl #77084] scalar //g match on overloaded object causesstring corruption
Message ID:
On Thu, Aug 19, 2010 at 06:38:08PM +0200, Abigail wrote:
> On Sun, Aug 08, 2010 at 02:36:31PM -0700, Father Chrysostomos wrote:
> > use Data::Dumper;
> > use overoad q/""/=>sub{"foo:bar"};
> > bless [], =~ /(.*)/g;
> > $Data::Dumper::Useqq++;
> > print Dumper "$1";
> > __END__
> > 
> > The output varies, but it’s usually something like:
> > 
> > $VAR1 = "\t\0\0\0\263\337!";
> I can confirm this.
> Included a TODO test for this in commit a9f6cb1.

This is now partially fixed with commit


More to the point, this fixes the original bug report, but doesn't pass
all the tests in t/re/overload.t. In particular, the pos() position after
the second (scalar) match is attached to $o, and re-used for the third
match (void), which then matches the zero-length string at the end.

I think this is correct behaviour and that the third test is wrong.

PS Abigail: why was a new test file created for this rather than just
adding to lib/overload.t ?

You never really learn to swear until you learn to drive.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About