develooper Front page | perl.perl5.porters | Postings from February 2013

[perl #59956] 'Modification of read-only value' when autovivifying via grep

Thread Next
From:
James E Keenan via RT
Date:
February 24, 2013 23:10
Subject:
[perl #59956] 'Modification of read-only value' when autovivifying via grep
Message ID:
rt-3.6.HEAD-31961-1361747398-141.59956-15-0@perl.org
On Sat Oct 18 18:05:45 2008, ikegami@adaelis.com wrote:
> On Fri, Oct 17, 2008 at 11:26 AM, via RT Ed Avis
> <perlbug-followup@perl.org>wrote:
> 
> > # New Ticket Created by  "Ed Avis"
> > # Please include the string:  [perl #59956]
> > # in the subject line of all future correspondence about this issue.
> > # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=59956 >
> >
> >
> > This is a bug report for perl from eda@waniasset.com,
> > generated with the help of perlbug 1.36 running under perl 5.10.0.
> >
> >
> > -----------------------------------------------------------------
> > [Please enter your report here]
> >
> > This test program
> >
> >    $a[1][0] = 'x';
> >    sub f { grep { grep { 0 } @$_ } @_ }
> >    f @a;
> >
> > produces the error
> >
> > Modification of a read-only value attempted at prog line 2.
> >
> > However no modification of any value was asked for.  The error message
> > should state more clearly what is happening.
> >
> 
> The read-only value in question is the undef at $a[0].
> The attempt to modify it is autovivification via @$_.
> 
> The correct code would be
>     sub f { grep { grep { 0 } $_ ? @$_ : () } @_ }
> or the slightly wasteful
>     sub f { grep { grep { 0 } @{ $_ || [] } } @_ }
> 
> Surely the error message could be improved?

There have been no responses to Eric's post or the original post in more
than four years.

Does anyone feel this issue should be taken on?  If not, the absence of
discussion in that period of time suggests the ticket can be closed.

Thank you very much.
Jim Keenan

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=59956

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