Code assumes that *FOO{SCALAR} will always return a scalar reference,
authorNicholas Clark <nick@ccl4.org>
Mon, 30 Jan 2006 13:42:56 +0000 (13:42 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 30 Jan 2006 13:42:56 +0000 (13:42 +0000)
so make it so, creating $FOO if necessary.
(Effectively this is a policy decision that PERL_DONT_CREATE_GVSV is
visible to XS code, but isn't visible to Perl code)

p4raw-id: //depot/perl@27002

pp.c
t/op/gv.t

diff --git a/pp.c b/pp.c
index 9676ce6..96d5ef6 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -607,7 +607,7 @@ PP(pp_gelem)
            break;
        case 'S':
            if (strEQ(second_letter, "CALAR"))
-               tmpRef = GvSV(gv);
+               tmpRef = GvSVn(gv);
            break;
        }
     }
index cf4108a..2230baf 100755 (executable)
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -12,7 +12,7 @@ BEGIN {
 use warnings;
 
 require './test.pl';
-plan( tests => 132 );
+plan( tests => 134 );
 
 # type coersion on assignment
 $foo = 'foo';
@@ -393,6 +393,19 @@ foreach my $value ([1,2,3], {1=>2}, *STDOUT{IO}, \&ok, *STDOUT{FORMAT}) {
     like ($@, qr/^Cannot convert a reference to $type to typeglob/,
          "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");
+}
+
 __END__
 Perl
 Rules