diff options
-rw-r--r-- | pp.c | 2 | ||||
-rwxr-xr-x | t/op/ref.t | 16 |
2 files changed, 14 insertions, 4 deletions
@@ -512,6 +512,8 @@ refto(SV *sv) vivify_defelem(sv); if (!(sv = LvTARG(sv))) sv = &PL_sv_undef; + else + SvREFCNT_inc(sv); } else if (SvPADTMP(sv)) sv = newSVsv(sv); diff --git a/t/op/ref.t b/t/op/ref.t index 1d70f9fd4c..618cfcc263 100755 --- a/t/op/ref.t +++ b/t/op/ref.t @@ -1,6 +1,6 @@ #!./perl -print "1..55\n"; +print "1..56\n"; # Test glob operations. @@ -271,14 +271,22 @@ print $$_,"\n"; print "# good, didn't recurse\n"; } +# test if refgen behaves with autoviv magic + +{ + my @a; + $a[1] = "ok 53\n"; + print ${\$_} for @a; +} + # test global destruction package FINALE; { - $ref3 = bless ["ok 55\n"]; # package destruction - my $ref2 = bless ["ok 54\n"]; # lexical destruction - local $ref1 = bless ["ok 53\n"]; # dynamic destruction + $ref3 = bless ["ok 56\n"]; # package destruction + my $ref2 = bless ["ok 55\n"]; # lexical destruction + local $ref1 = bless ["ok 54\n"]; # dynamic destruction 1; # flush any temp values on stack } |