Fix bug #41550 - AUTOLOAD :lvalue not working the same in blead as in
authorNicholas Clark <nick@ccl4.org>
Mon, 26 Feb 2007 11:07:06 +0000 (11:07 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 26 Feb 2007 11:07:06 +0000 (11:07 +0000)
5.8.8 (a code example from "Extending and Embedding Perl")

p4raw-id: //depot/perl@30407

op.h
t/op/sub_lval.t

diff --git a/op.h b/op.h
index 746e635..1505932 100644 (file)
--- a/op.h
+++ b/op.h
@@ -203,14 +203,14 @@ Deprecated.  Use C<GIMME_V> instead.
 #define OPpLVAL_DEFER          16      /* Defer creation of array/hash elem */
   /* OP_RV2?V, OP_GVSV, OP_ENTERITER only */
 #define OPpOUR_INTRO           16      /* Variable was in an our() */
-  /* OP_RV2[AH]V, OP_PAD[AH]V, OP_[AH]ELEM */
+  /* OP_RV2[AGH]V, OP_PAD[AH]V, OP_[AH]ELEM */
 #define OPpMAYBE_LVSUB         8       /* We might be an lvalue to return */
   /* OP_PADSV only */
 #define OPpPAD_STATE           16      /* is a "state" pad */
   /* for OP_RV2?V, lower bits carry hints (currently only HINT_STRICT_REFS) */
 
   /* OP_RV2GV only */
-#define OPpDONT_INIT_GV                8       /* Call gv_fetchpv with GV_NOINIT */
+#define OPpDONT_INIT_GV                4       /* Call gv_fetchpv with GV_NOINIT */
 /* (Therefore will return whatever is currently in the symbol table, not
    guaranteed to be a PVGV)  */
 
index 2e4db52..a159bac 100755 (executable)
@@ -3,7 +3,7 @@ BEGIN {
     @INC = '../lib';
     require './test.pl';
 }
-plan tests=>68;
+plan tests=>69;
 
 sub a : lvalue { my $a = 34; ${\(bless \$a)} }  # Return a temporary
 sub b : lvalue { ${\shift} }
@@ -539,3 +539,14 @@ TODO: {
 
     is($line, "zeroonetwothree");
 }
+
+{
+    package Foo;
+    sub AUTOLOAD :lvalue { *{$AUTOLOAD} };
+    package main;
+    my $foo = bless {},"Foo";
+    my $result;
+    $foo->bar = sub { $result = "bar" };
+    $foo->bar;
+    is ($result, 'bar', "RT #41550");
+}