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
From:
Dave Mitchell
Date:
September 1, 2010 09:16
Subject:
Re: [perl #77084] scalar //g match on overloaded object causesstring corruption
Message ID:
20100901161607.GB2892@iabyn.com
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

    f427b557f0f598ee6ff57dfc24080cf33d959242

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.
Opinions?

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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About