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

[perl #69456] ck_rvconst rejects glob-as-scalar

Thread Next
From:
Father Chrysostomos via RT
Date:
July 3, 2013 05:32
Subject:
[perl #69456] ck_rvconst rejects glob-as-scalar
Message ID:
rt-3.6.HEAD-2552-1372829524-64.69456-15-0@perl.org
On Mon Sep 28 15:34:35 2009, zefram@fysh.org wrote:
> 
> This is a bug report for perl from zefram@fysh.org,
> generated with the help of perlbug 1.36 running under perl 5.10.0.
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
> I'm doing some XS work that involves generating rv2sv ops where the
> reference is a const op holding an RV that points at a suitable SV.
> If the suitable SV is a GV, ck_rvconst rejects it, saying "Constant is
> not a SCALAR reference".  Actually GVs are valid as scalars:
> 
> $ perl -lwe '$foo=123; $glob=*foo; print ${*{\$glob}{SCALAR}}'
> 123
> 
> so I reckon ck_rvconst should not be rejecting it.  It should probably
> also allow SVt_PVLV scalars.

It also breaks things like this:

use constant foo=>\$_;
bless \$_;
use overload '@{}' => sub { [1,2,3] };
print foo->[1], "\n";

Why shouldn’t that work?  I suggest removing that compile time check
altogether (but still making sure references don’t fall through to the
bareword lookup [come to think of it, other stuff probably also makes
its way through that code path erroneously (such as globs)]).

-- 

Father Chrysostomos


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

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