From b66f10a9ff2efe82ee9c8d887dde53d78dc8fb5c Mon Sep 17 00:00:00 2001 From: Zefram Date: Tue, 13 Apr 2010 23:42:50 +0100 Subject: [perl #73666] *foo{SCALAR} should not autovivify --- pp.c | 2 +- t/op/gv.t | 35 ++++++++++++++++++++++------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/pp.c b/pp.c index 9565c6c473..ea680f9dd0 100644 --- a/pp.c +++ b/pp.c @@ -658,7 +658,7 @@ PP(pp_gelem) break; case 'S': if (strEQ(second_letter, "CALAR")) - tmpRef = GvSVn(gv); + tmpRef = GvSV(gv); break; } } diff --git a/t/op/gv.t b/t/op/gv.t index 382e3f0157..c154eb2e37 100644 --- a/t/op/gv.t +++ b/t/op/gv.t @@ -12,7 +12,7 @@ BEGIN { use warnings; require './test.pl'; -plan( tests => 188 ); +plan( tests => 202 ); # type coersion on assignment $foo = 'foo'; @@ -483,18 +483,6 @@ foreach my $value ([1,2,3], {1=>2}, *STDOUT{IO}, \&ok, *STDOUT{FORMAT}) { "Cannot upgrade ref-to-$type to typeglob"); } -{ - no warnings qw(once uninitialized); - my $g = \*clatter; - my $r = eval {no strict; ${*{$g}{SCALAR}}}; - is ($@, '', "PERL_DONT_CREATE_GVSV shouldn't affect thingy syntax"); - - $g = \*vowm; - $r = eval {use strict; ${*{$g}{SCALAR}}}; - is ($@, '', - "PERL_DONT_CREATE_GVSV shouldn't affect thingy syntax under strict"); -} - { # Bug reported by broquaint on IRC *slosh::{HASH}->{ISA}=[]; @@ -614,6 +602,27 @@ ok(exists($RT72740a::{s4}), "RT72740a::s4 exists"); is(RT72740a::s1(), "RT72740b::s2", "RT72740::s1 parsed correctly"); is(RT72740a::s3(), "RT72740b::s4", "RT72740::s3 parsed correctly"); +$RT73666::scalar = undef; +isnt(*RT73666::scalar{SCALAR}, undef, "scalar vivified correctly"); +is(*RT73666::scalar{ARRAY}, undef, "scalar doesn't autovivify array"); +is(*RT73666::scalar{HASH}, undef, "scalar doesn't autovivify hash"); +is(*RT73666::scalar{CODE}, undef, "scalar doesn't autovivify code"); +@RT73666::array = (); +is(*RT73666::array{SCALAR}, undef, "array doesn't autovivify scalar"); +isnt(*RT73666::array{ARRAY}, undef, "array vivified correctly"); +is(*RT73666::array{HASH}, undef, "array doesn't autovivify hash"); +is(*RT73666::array{CODE}, undef, "array doesn't autovivify code"); +%RT73666::hash = (); +is(*RT73666::hash{SCALAR}, undef, "hash doesn't autovivify scalar"); +is(*RT73666::hash{ARRAY}, undef, "hash doesn't autovivify array"); +isnt(*RT73666::hash{HASH}, undef, "hash vivified correctly"); +is(*RT73666::hash{CODE}, undef, "hash doesn't autovivify code"); +sub RT73666::code { } +is(*RT73666::code{SCALAR}, undef, "code doesn't autovivify scalar"); +is(*RT73666::code{ARRAY}, undef, "code doesn't autovivify array"); +is(*RT73666::code{HASH}, undef, "code doesn't autovivify hash"); +isnt(*RT73666::code{CODE}, undef, "code vivified correctly"); + __END__ Perl Rules -- cgit v1.2.1