From: Shinya Hayakawa Date: Tue, 25 May 2004 00:06:06 +0000 (+0900) Subject: Re: my $x->{foo} doesn't work X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a62b51b8b5ba4453033358d44b4729c019d6ae42;p=p5sagit%2Fp5-mst-13.2.git Re: my $x->{foo} doesn't work Message-Id: <200405250006.06387.hayakawa@livedoor.jp> Allow autovivification of (my $x)->{foo} p4raw-id: //depot/perl@22874 --- diff --git a/pp_hot.c b/pp_hot.c index d02bf96..c3ce802 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -200,7 +200,7 @@ PP(pp_padsv) if (PL_op->op_flags & OPf_MOD) { if (PL_op->op_private & OPpLVAL_INTRO) SAVECLEARSV(PAD_SVl(PL_op->op_targ)); - else if (PL_op->op_private & OPpDEREF) { + if (PL_op->op_private & OPpDEREF) { PUTBACK; vivify_ref(PAD_SVl(PL_op->op_targ), PL_op->op_private & OPpDEREF); SPAGAIN; diff --git a/t/op/my.t b/t/op/my.t index bf5b6db..6feabe4 100755 --- a/t/op/my.t +++ b/t/op/my.t @@ -2,7 +2,7 @@ # $RCSfile: my.t,v $ -print "1..33\n"; +print "1..34\n"; sub foo { my($a, $b) = @_; @@ -111,3 +111,14 @@ print "ok 32\n"; eval { my $x = opth }; print "not " if $@; print "ok 33\n"; + + +sub foo3 { + ++my $x->{foo}; + print "not " if defined $x->{bar}; + ++$x->{bar}; +} +eval { foo3(); foo3(); }; +print "not " if $@; +print "ok 34\n"; +