develooper Front page | perl.perl5.porters | Postings from May 2004

Re: my $x->{foo} doesn't work

Thread Previous | Thread Next
From:
Shinya Hayakawa
Date:
May 24, 2004 15:28
Subject:
Re: my $x->{foo} doesn't work
Message ID:
200405250006.06387.hayakawa@livedoor.jp
Hi,

On Friday 21 May 2004 11:04 pm, hv@crypt.org wrote:
> I have nothing in principle against including this, except that it is
> missing tests. Perhaps you could have a go at adding some tests to
> explore the edge cases around this - a good starting point, for example,
> would be to find a test case that exposes the problem with your first
> attempt at this patch.

I wrote the patch which includes the tests.
Thank you so much for your resposes to my
recent mail. Would please indicate me if there
were any mistakes.


--- pp_hot.c.orig	2004-05-21 10:49:37.000000000 +0900
+++ pp_hot.c	2004-05-24 21:20:41.000000000 +0900
@@ -204,7 +204,7 @@
     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;
--- t/op/my.t.orig	2004-05-24 20:27:08.000000000 +0900
+++ t/op/my.t	2004-05-25 00:01:53.000000000 +0900
@@ -2,7 +2,7 @@
 
 # $RCSfile: my.t,v $
 
-print "1..31\n";
+print "1..32\n";
 
 sub foo {
     my($a, $b) = @_;
@@ -99,3 +99,12 @@
     # Supposed to be copy-on-write via force_normal after a THINKFIRST check.
     print "$full $fonts{nok}\n";
 }
+
+sub foo3 {
+    ++my $x->{foo};
+    print "not " if defined $x->{bar};
+    ++$x->{bar};
+}
+eval { foo3(); foo3(); };
+print "not " if $@;
+print "ok 32\n";


-- 
Shinya Hayakawa
hayakawa@livedoor.jp


Thread Previous | 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