develooper Front page | perl.perl5.porters | Postings from June 2016

[perl #128479] Assigning hashref to symtable not an error since(somewhere before 5.21.10 )

Thread Next
From:
Father Chrysostomos via RT
Date:
June 25, 2016 14:36
Subject:
[perl #128479] Assigning hashref to symtable not an error since(somewhere before 5.21.10 )
Message ID:
rt-4.0.18-26429-1466865388-512.128479-15-0@perl.org
On Sat Jun 25 07:31:51 2016, sprout wrote:
> $ perl5.12 -e 'BEGIN {$Foo::{bar} = {}} Foo::bar()'
> Cannot convert a reference to HASH to typeglob at -e line 1.
> $ perl5.10 -e 'BEGIN {$Foo::{bar} = {}} warn defined Foo::bar()'
> Warning: something's wrong at -e line 1.
> $ perl5.8.7 -e 'BEGIN {$Foo::{bar} = {}} Foo::bar()'
> Undefined subroutine &Foo::bar called at -e line 1.
> 
> So this was not terribly consistent to begin with. :-)

It’s being treated as a constant:

$ ./perl -Ilib -MO=Concise -e 'BEGIN {$Foo::{bar} = {}} Foo::bar()'
3  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 3 -e:1) v:{ ->3
-     <0> ex-const v*/FOLD ->3
-e syntax OK

BTW, perlmod says:

The results of creating new symbol table entries directly or modifying any
entries that are not already typeglobs are undefined and subject to change
between releases of perl.

So this is technically not a bug. :-)

-- 

Father Chrysostomos


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

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