7 no warnings 'deprecated';
11 # this used to segfault (because $[=1 is optimized away to a null block)
15 $[ = 0; # restore the original value for less side-effects
18 # [perl #36313] perl -e "1for$[=0" crash
22 pass('optimized assignment to $[ used to segfault in list context');
23 if ($[ = 0) { $x = 1 }
24 pass('optimized assignment to $[ used to segfault in scalar context');
26 is($x, 2, 'scalar assignment to $[ behaves like other variables');
28 is($x, 1, 'list assignment to $[ behaves like other variables');
29 $x = eval q{ ($[, $x) = (0) };
30 like($@, qr/That use of \$\[ is unsupported/,
31 'cannot assign to $[ in a list');
32 eval q{ ($[) = (0, 1) };
33 like($@, qr/That use of \$\[ is unsupported/,
34 'cannot assign list of >1 elements to $[');
36 like($@, qr/That use of \$\[ is unsupported/,
37 'cannot assign list of <1 elements to $[');