summaryrefslogtreecommitdiff
path: root/t/comp
diff options
context:
space:
mode:
authorRick Delaney <rick@consumercontact.com>2005-06-19 05:47:22 -0400
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-06-20 09:06:57 +0000
commitdbfe47cffca44e11296e0f81e2a3b0d4458a8ba4 (patch)
tree83294a2569a5421db0d802f63d961ab2a4ed41d2 /t/comp
parentcb4415b833301d0ffacb0772b2914f6cd6acc2f8 (diff)
downloadperl-dbfe47cffca44e11296e0f81e2a3b0d4458a8ba4.tar.gz
Re: [PATCH replacement] Re: [perl #36313] perl -e "1for$[=0" crash
Message-ID: <20050619134722.GB31592@localhost.localdomain> p4raw-id: //depot/perl@24901
Diffstat (limited to 't/comp')
-rw-r--r--t/comp/parser.t24
1 files changed, 23 insertions, 1 deletions
diff --git a/t/comp/parser.t b/t/comp/parser.t
index d784373c29..645e6e21ca 100644
--- a/t/comp/parser.t
+++ b/t/comp/parser.t
@@ -9,7 +9,7 @@ BEGIN {
}
require "./test.pl";
-plan( tests => 47 );
+plan( tests => 54 );
eval '%@x=0;';
like( $@, qr/^Can't modify hash dereference in repeat \(x\)/, '%@x=0' );
@@ -168,3 +168,25 @@ EOF
eval q{ sub _ __FILE__ {} };
like($@, qr/Illegal declaration of subroutine main::_/, "__FILE__ as prototype");
}
+
+# [perl #36313] perl -e "1for$[=0" crash
+{
+ my $x;
+ $x = 1 for ($[) = 0;
+ pass('optimized assignment to $[ used to segfault in list context');
+ if ($[ = 0) { $x = 1 }
+ pass('optimized assignment to $[ used to segfault in scalar context');
+ $x = ($[=2.4);
+ is($x, 2, 'scalar assignment to $[ behaves like other variables');
+ $x = (($[) = 0);
+ is($x, 1, 'list assignment to $[ behaves like other variables');
+ $x = eval q{ ($[, $x) = (0) };
+ like($@, qr/That use of \$\[ is unsupported/,
+ 'cannot assign to $[ in a list');
+ eval q{ ($[) = (0, 1) };
+ like($@, qr/That use of \$\[ is unsupported/,
+ 'cannot assign list of >1 elements to $[');
+ eval q{ ($[) = () };
+ like($@, qr/That use of \$\[ is unsupported/,
+ 'cannot assign list of <1 elements to $[');
+}