summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2004-03-27 01:54:09 +0000
committerDave Mitchell <davem@fdisolutions.com>2004-03-27 01:54:09 +0000
commit781e754729fc501417aaa89f25dc83f904a17c5c (patch)
treeacd18394b24e1dee6d0d3d8d64564808b9a1195c /t
parent314d47789e6f2fb6e6cb6d9aa287d0766ea79b45 (diff)
downloadperl-781e754729fc501417aaa89f25dc83f904a17c5c.tar.gz
[perl #24200] string corruption with lvalue sub
Depending on the context, the same substr OP may want to return a PVLV or an LV on subsequent invcations. If TARG is the wrong type, use a mortal instead. p4raw-id: //depot/perl@22599
Diffstat (limited to 't')
-rwxr-xr-xt/op/substr.t13
1 files changed, 12 insertions, 1 deletions
diff --git a/t/op/substr.t b/t/op/substr.t
index ad35dce8cb..681ac6d7a6 100755
--- a/t/op/substr.t
+++ b/t/op/substr.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..186\n";
+print "1..188\n";
#P = start of string Q = start of substr R = end of substr S = end of string
@@ -629,3 +629,14 @@ ok 174, $x eq "\x{100}\x{200}\xFFb";
ok 186, $x eq 'aYYYYef';
}
}
+
+# [perl #24200] string corruption with lvalue sub
+
+{
+ my $foo = "a";
+ sub bar: lvalue { substr $foo, 0 }
+ bar = "XXX";
+ ok 187, bar eq 'XXX';
+ $foo = '123456789';
+ ok 188, bar eq '123456789';
+}