This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
576cd7456f902ea7192f2a559b5f12c1faf3d226
[perl5.git] / lib / B / Deparse.t
1 #!./perl
2
3 BEGIN {
4     splice @INC, 0, 0, 't', '.';
5     require Config;
6     if (($Config::Config{'extensions'} !~ /\bB\b/) ){
7         print "1..0 # Skip -- Perl configured without B module\n";
8         exit 0;
9     }
10     require 'test.pl';
11 }
12
13 use warnings;
14 use strict;
15
16 my $tests = 52; # not counting those in the __DATA__ section
17
18 use B::Deparse;
19 my $deparse = B::Deparse->new();
20 isa_ok($deparse, 'B::Deparse', 'instantiate a B::Deparse object');
21 my %deparse;
22
23 $/ = "\n####\n";
24 while (<DATA>) {
25     chomp;
26     $tests ++;
27     # This code is pinched from the t/lib/common.pl for TODO.
28     # It's not clear how to avoid duplication
29     my %meta = (context => '');
30     foreach my $what (qw(skip todo context options)) {
31         s/^#\s*\U$what\E\s*(.*)\n//m and $meta{$what} = $1;
32         # If the SKIP reason starts ? then it's taken as a code snippet to
33         # evaluate. This provides the flexibility to have conditional SKIPs
34         if ($meta{$what} && $meta{$what} =~ s/^\?//) {
35             my $temp = eval $meta{$what};
36             if ($@) {
37                 die "# In \U$what\E code reason:\n# $meta{$what}\n$@";
38             }
39             $meta{$what} = $temp;
40         }
41     }
42
43     s/^\s*#\s*(.*)$//mg;
44     my $desc = $1;
45     die "Missing name in test $_" unless defined $desc;
46
47     if ($meta{skip}) {
48         SKIP: { skip($meta{skip}) };
49         next;
50     }
51
52     my ($input, $expected);
53     if (/(.*)\n>>>>\n(.*)/s) {
54         ($input, $expected) = ($1, $2);
55     }
56     else {
57         ($input, $expected) = ($_, $_);
58     }
59
60     # parse options if necessary
61     my $deparse = $meta{options}
62         ? $deparse{$meta{options}} ||=
63             new B::Deparse split /,/, $meta{options}
64         : $deparse;
65
66     my $code = "$meta{context};\n" . <<'EOC' . "sub {$input\n}";
67 # Tell B::Deparse about our ambient pragmas
68 my ($hint_bits, $warning_bits, $hinthash);
69 BEGIN {
70     ($hint_bits, $warning_bits, $hinthash) = ($^H, ${^WARNING_BITS}, \%^H);
71 }
72 $deparse->ambient_pragmas (
73     hint_bits    => $hint_bits,
74     warning_bits => $warning_bits,
75     '%^H'        => $hinthash,
76 );
77 EOC
78     my $coderef = eval $code;
79
80     local $::TODO = $meta{todo};
81     if ($@) {
82         is($@, "", "compilation of $desc")
83             or diag "=============================================\n"
84                   . "CODE:\n--------\n$code\n--------\n"
85                   . "=============================================\n";
86     }
87     else {
88         my $deparsed = $deparse->coderef2text( $coderef );
89         my $regex = $expected;
90         $regex =~ s/(\S+)/\Q$1/g;
91         $regex =~ s/\s+/\\s+/g;
92         $regex = '^\{\s*' . $regex . '\s*\}$';
93
94         like($deparsed, qr/$regex/, $desc)
95             or diag "=============================================\n"
96                   . "CODE:\n--------\n$input\n--------\n"
97                   . "EXPECTED:\n--------\n{\n$expected\n}\n--------\n"
98                   . "GOT:\n--------\n$deparsed\n--------\n"
99                   . "=============================================\n";
100     }
101 }
102
103 # Reset the ambient pragmas
104 {
105     my ($b, $w, $h);
106     BEGIN {
107         ($b, $w, $h) = ($^H, ${^WARNING_BITS}, \%^H);
108     }
109     $deparse->ambient_pragmas (
110         hint_bits    => $b,
111         warning_bits => $w,
112         '%^H'        => $h,
113     );
114 }
115
116 use constant 'c', 'stuff';
117 is((eval "sub ".$deparse->coderef2text(\&c))->(), 'stuff',
118    'the subroutine generated by use constant deparses');
119
120 my $a = 0;
121 is($deparse->coderef2text(sub{(-1) ** $a }), "{\n    (-1) ** \$a;\n}",
122    'anon sub capturing an external lexical');
123
124 use constant cr => ['hello'];
125 my $string = "sub " . $deparse->coderef2text(\&cr);
126 my $val = (eval $string)->() or diag $string;
127 is(ref($val), 'ARRAY', 'constant array references deparse');
128 is($val->[0], 'hello', 'and return the correct value');
129
130 my $path = join " ", map { qq["-I$_"] } @INC;
131
132 $a = `$^X $path "-MO=Deparse" -anlwi.bak -e 1 2>&1`;
133 $a =~ s/-e syntax OK\n//g;
134 $a =~ s/.*possible typo.*\n//;     # Remove warning line
135 $a =~ s/.*-i used with no filenames.*\n//;      # Remove warning line
136 $b = quotemeta <<'EOF';
137 BEGIN { $^I = ".bak"; }
138 BEGIN { $^W = 1; }
139 BEGIN { $/ = "\n"; $\ = "\n"; }
140 LINE: while (defined($_ = readline ARGV)) {
141     chomp $_;
142     our(@F) = split(' ', $_, 0);
143     '???';
144 }
145 EOF
146 $b =~ s/our\\\(\\\@F\\\)/our[( ]\@F\\)?/; # accept both our @F and our(@F)
147 like($a, qr/$b/,
148    'command line flags deparse as BEGIN blocks setting control variables');
149
150 $a = `$^X $path "-MO=Deparse" -e "use constant PI => 4" 2>&1`;
151 $a =~ s/-e syntax OK\n//g;
152 is($a, "use constant ('PI', 4);\n",
153    "Proxy Constant Subroutines must not show up as (incorrect) prototypes");
154
155 $a = `$^X $path "-MO=Deparse" -e "sub foo(){1}" 2>&1`;
156 $a =~ s/-e syntax OK\n//g;
157 is($a, "sub foo () {\n    1;\n}\n",
158    "Main prog consisting of just a constant (via empty proto)");
159
160 $a = readpipe qq|$^X $path "-MO=Deparse"|
161              .qq| -e "package F; sub f(){0} sub s{}"|
162              .qq| -e "#line 123 four-five-six"|
163              .qq| -e "package G; sub g(){0} sub s{}" 2>&1|;
164 $a =~ s/-e syntax OK\n//g;
165 like($a, qr/sub F::f \(\) \{\s*0;?\s*}/,
166    "Constant is dumped in package in which other subs are dumped");
167 unlike($a, qr/sub g/,
168    "Constant is not dumped in package in which other subs are not dumped");
169
170 #Re: perlbug #35857, patch #24505
171 #handle warnings::register-ed packages properly.
172 package B::Deparse::Wrapper;
173 use strict;
174 use warnings;
175 use warnings::register;
176 sub getcode {
177    my $deparser = B::Deparse->new();
178    return $deparser->coderef2text(shift);
179 }
180
181 package Moo;
182 use overload '0+' => sub { 42 };
183
184 package main;
185 use strict;
186 use warnings;
187 use constant GLIPP => 'glipp';
188 use constant PI => 4;
189 use constant OVERLOADED_NUMIFICATION => bless({}, 'Moo');
190 use Fcntl qw/O_TRUNC O_APPEND O_EXCL/;
191 BEGIN { delete $::Fcntl::{O_APPEND}; }
192 use POSIX qw/O_CREAT/;
193 sub test {
194    my $val = shift;
195    my $res = B::Deparse::Wrapper::getcode($val);
196    like($res, qr/use warnings/,
197         '[perl #35857] [PATCH] B::Deparse doesnt handle warnings register properly');
198 }
199 my ($q,$p);
200 my $x=sub { ++$q,++$p };
201 test($x);
202 eval <<EOFCODE and test($x);
203    package bar;
204    use strict;
205    use warnings;
206    use warnings::register;
207    package main;
208    1
209 EOFCODE
210
211 # Exotic sub declarations
212 $a = `$^X $path "-MO=Deparse" -e "sub ::::{}sub ::::::{}" 2>&1`;
213 $a =~ s/-e syntax OK\n//g;
214 is($a, <<'EOCODG', "sub :::: and sub ::::::");
215 sub :::: {
216     
217 }
218 sub :::::: {
219     
220 }
221 EOCODG
222
223 # [perl #117311]
224 $a = `$^X $path "-MO=Deparse,-l" -e "map{ eval(0) }()" 2>&1`;
225 $a =~ s/-e syntax OK\n//g;
226 is($a, <<'EOCODH', "[perl #117311] [PATCH] -l option ('#line ...') does not emit ^Ls in the output");
227 #line 1 "-e"
228 map {
229 #line 1 "-e"
230 eval 0;} ();
231 EOCODH
232
233 # [perl #33752]
234 {
235   my $code = <<"EOCODE";
236 {
237     our \$\x{1e1f}\x{14d}\x{14d};
238 }
239 EOCODE
240   my $deparsed
241    = $deparse->coderef2text(eval "sub { our \$\x{1e1f}\x{14d}\x{14d} }" );
242   s/$ \n//x for $deparsed, $code;
243   is $deparsed, $code, 'our $funny_Unicode_chars';
244 }
245
246 # [perl #62500]
247 $a =
248   `$^X $path "-MO=Deparse" -e "BEGIN{*CORE::GLOBAL::require=sub{1}}" 2>&1`;
249 $a =~ s/-e syntax OK\n//g;
250 is($a, <<'EOCODF', "CORE::GLOBAL::require override causing panick");
251 sub BEGIN {
252     *CORE::GLOBAL::require = sub {
253         1;
254     }
255     ;
256 }
257 EOCODF
258
259 # [perl #91384]
260 $a =
261   `$^X $path "-MO=Deparse" -e "BEGIN{*Acme::Acme:: = *Acme::}" 2>&1`;
262 like($a, qr/-e syntax OK/,
263     "Deparse does not hang when traversing stash circularities");
264
265 # [perl #93990]
266 @] = ();
267 is($deparse->coderef2text(sub{ print "foo@{]}" }),
268 q<{
269     print "foo@{]}";
270 }>, 'curly around to interpolate "@{]}"');
271 is($deparse->coderef2text(sub{ print "foo@{-}" }),
272 q<{
273     print "foo@-";
274 }>, 'no need to curly around to interpolate "@-"');
275
276 # Strict hints in %^H are mercilessly suppressed
277 $a =
278   `$^X $path "-MO=Deparse" -e "use strict; print;" 2>&1`;
279 unlike($a, qr/BEGIN/,
280     "Deparse does not emit strict hh hints");
281
282 # ambient_pragmas should not mess with strict settings.
283 SKIP: {
284     skip "requires 5.11", 1 unless $] >= 5.011;
285     eval q`
286         BEGIN {
287             # Clear out all hints
288             %^H = ();
289             $^H = 0;
290             new B::Deparse -> ambient_pragmas(strict => 'all');
291         }
292         use 5.011;  # should enable strict
293         ok !eval '$do_noT_create_a_variable_with_this_name = 1',
294           'ambient_pragmas do not mess with compiling scope';
295    `;
296 }
297
298 # multiple statements on format lines
299 $a = `$^X $path "-MO=Deparse" -e "format =" -e "\@" -e "x();z()" -e. 2>&1`;
300 $a =~ s/-e syntax OK\n//g;
301 is($a, <<'EOCODH', 'multiple statements on format lines');
302 format STDOUT =
303 @
304 x(); z()
305 .
306 EOCODH
307
308 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path, '-T' ],
309            prog => "format =\n\@\n\$;\n.\n"),
310    <<'EOCODM', '$; on format line';
311 format STDOUT =
312 @
313 $;
314 .
315 EOCODM
316
317 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse,-l', $path ],
318            prog => "format =\n\@\n\$foo\n.\n"),
319    <<'EOCODM', 'formats with -l';
320 format STDOUT =
321 @
322 $foo
323 .
324 EOCODM
325
326 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
327            prog => "{ my \$x; format =\n\@\n\$x\n.\n}"),
328    <<'EOCODN', 'formats nested inside blocks';
329 {
330     my $x;
331     format STDOUT =
332 @
333 $x
334 .
335 }
336 EOCODN
337
338 # CORE::format
339 $a = readpipe qq`$^X $path "-MO=Deparse" -e "use feature q|:all|;`
340              .qq` my sub format; CORE::format =" -e. 2>&1`;
341 like($a, qr/CORE::format/, 'CORE::format when lex format sub is in scope');
342
343 # literal big chars under 'use utf8'
344 is($deparse->coderef2text(sub{ use utf8; /€/; }),
345 '{
346     /\x{20ac}/;
347 }',
348 "qr/euro/");
349
350 # STDERR when deparsing sub calls
351 # For a short while the output included 'While deparsing'
352 $a = `$^X $path "-MO=Deparse" -e "foo()" 2>&1`;
353 $a =~ s/-e syntax OK\n//g;
354 is($a, <<'EOCODI', 'no extra output when deparsing foo()');
355 foo();
356 EOCODI
357
358 # Sub calls compiled before importation
359 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
360              prog => 'BEGIN {
361                        require Test::More;
362                        Test::More::->import;
363                        is(*foo, *foo)
364                      }'),
365      qr/&is\(/,
366     'sub calls compiled before importation of prototype subs';
367
368 # [perl #121050] Prototypes with whitespace
369 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
370            prog => <<'EOCODO'),
371 sub _121050(\$ \$) { }
372 _121050($a,$b);
373 sub _121050empty( ) {}
374 () = _121050empty() + 1;
375 EOCODO
376    <<'EOCODP', '[perl #121050] prototypes with whitespace';
377 sub _121050 (\$ \$) {
378     
379 }
380 _121050 $a, $b;
381 sub _121050empty ( ) {
382     
383 }
384 () = _121050empty + 1;
385 EOCODP
386
387 # CORE::no
388 $a = readpipe qq`$^X $path "-MO=Deparse" -Xe `
389              .qq`"use feature q|:all|; my sub no; CORE::no less" 2>&1`;
390 like($a, qr/my sub no;\n.*CORE::no less;/s,
391     'CORE::no after my sub no');
392
393 # CORE::use
394 $a = readpipe qq`$^X $path "-MO=Deparse" -Xe `
395              .qq`"use feature q|:all|; my sub use; CORE::use less" 2>&1`;
396 like($a, qr/my sub use;\n.*CORE::use less;/s,
397     'CORE::use after my sub use');
398
399 # CORE::__DATA__
400 $a = readpipe qq`$^X $path "-MO=Deparse" -Xe `
401              .qq`"use feature q|:all|; my sub __DATA__; `
402              .qq`CORE::__DATA__" 2>&1`;
403 like($a, qr/my sub __DATA__;\n.*CORE::__DATA__/s,
404     'CORE::__DATA__ after my sub __DATA__');
405
406 # sub declarations
407 $a = readpipe qq`$^X $path "-MO=Deparse" -e "sub foo{}" 2>&1`;
408 like($a, qr/sub foo\s*\{\s+\}/, 'sub declarations');
409 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
410            prog => 'sub f($); sub f($){}'),
411      qr/sub f\s*\(\$\)\s*\{\s*\}/,
412     'predeclared prototyped subs';
413 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
414            prog => 'use Scalar::Util q-weaken-;
415                     sub f($);
416                     BEGIN { weaken($_=\$::{f}) }'),
417      qr/sub f\s*\(\$\)\s*;/,
418     'prototyped stub with weak reference to the stash entry';
419 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
420            prog => 'sub f () { 42 }'),
421      qr/sub f\s*\(\)\s*\{\s*42;\s*\}/,
422     'constant perl sub declaration';
423
424 # BEGIN blocks
425 SKIP : {
426     skip "BEGIN output is wrong on old perls", 1 if $] < 5.021006;
427     my $prog = '
428       BEGIN { pop }
429       {
430         BEGIN { pop }
431         {
432           no overloading;
433           {
434             BEGIN { pop }
435             die
436           }
437         }
438       }';
439     $prog =~ s/\n//g;
440     $a = readpipe qq`$^X $path "-MO=Deparse" -e "$prog" 2>&1`;
441     $a =~ s/-e syntax OK\n//g;
442     is($a, <<'EOCODJ', 'BEGIN blocks');
443 sub BEGIN {
444     pop @ARGV;
445 }
446 {
447     sub BEGIN {
448         pop @ARGV;
449     }
450     {
451         no overloading;
452         {
453             sub BEGIN {
454                 pop @ARGV;
455             }
456             die;
457         }
458     }
459 }
460 EOCODJ
461 }
462 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ], prog => '
463       {
464         {
465           die;
466           BEGIN { pop }
467         }
468         BEGIN { pop }
469       }
470       BEGIN { pop }
471   '), <<'EOCODL', 'BEGIN blocks at the end of their enclosing blocks';
472 {
473     {
474         die;
475         sub BEGIN {
476             pop @ARGV;
477         }
478     }
479     sub BEGIN {
480         pop @ARGV;
481     }
482 }
483 sub BEGIN {
484     pop @ARGV;
485 }
486 EOCODL
487
488 # BEGIN blocks should not be called __ANON__
489 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
490              prog => 'sub BEGIN { } CHECK { delete $::{BEGIN} }'),
491      qr/sub BEGIN/, 'anonymised BEGIN';
492
493 # [perl #115066]
494 my $prog = 'use constant FOO => do { 1 }; no overloading; die';
495 $a = readpipe qq`$^X $path "-MO=-qq,Deparse" -e "$prog" 2>&1`;
496 is($a, <<'EOCODK', '[perl #115066] use statements accidentally nested');
497 use constant ('FOO', do {
498     1
499 });
500 no overloading;
501 die;
502 EOCODK
503
504 # BEGIN blocks inside predeclared subs
505 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
506              prog => '
507                  sub run_tests;
508                  run_tests();
509                  sub run_tests { BEGIN { } die }'),
510      qr/sub run_tests \{\s*sub BEGIN/,
511     'BEGIN block inside predeclared sub';
512
513 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
514              prog => 'package foo; use overload qr=>sub{}'),
515      qr/package foo;\s*use overload/,
516     'package, then use';
517
518 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
519              prog => 'use feature lexical_subs=>; my sub f;sub main::f{}'),
520      qr/^sub main::f \{/m,
521     'sub decl when lex sub is in scope';
522
523 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
524              prog => 'sub foo{foo()}'),
525      qr/^sub foo \{\s+foo\(\)/m,
526     'recursive sub';
527
528 like runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
529              prog => 'use feature lexical_subs=>state=>;
530                       state sub sb5; sub { sub sb5 { } }'),
531      qr/sub \{\s*\(\);\s*sub sb5 \{/m,
532     'state sub in anon sub but declared outside';
533
534 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
535              prog => 'BEGIN { $::{f}=\!0 }'),
536    "sub BEGIN {\n    \$main::{'f'} = \\1;\n}\n",
537    '&PL_sv_yes constant (used to croak)';
538
539 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path, '-T' ],
540            prog => '$x =~ (1?/$a/:0)'),
541   '$x =~ ($_ =~ /$a/);'."\n",
542   '$foo =~ <branch-folded match> under taint mode';
543
544 unlike runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path, '-w' ],
545                prog => 'BEGIN { undef &foo }'),
546        qr'Use of uninitialized value',
547       'no warnings for undefined sub';
548
549 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
550     prog => 'sub f { 1; } BEGIN { *g = \&f; }'),
551     "sub f {\n    1;\n}\nsub BEGIN {\n    *g = \\&f;\n}\n",
552     "sub glob alias shouldn't impede emitting original sub";
553
554 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
555     prog => 'package Foo; sub f { 1; } BEGIN { *g = \&f; }'),
556     "package Foo;\nsub f {\n    1;\n}\nsub BEGIN {\n    *g = \\&f;\n}\n",
557     "sub glob alias outside main shouldn't impede emitting original sub";
558
559 is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse', $path ],
560     prog => 'package Foo; sub f { 1; } BEGIN { *Bar::f = \&f; }'),
561     "package Foo;\nsub f {\n    1;\n}\nsub BEGIN {\n    *Bar::f = \\&f;\n}\n",
562     "sub glob alias in separate package shouldn't impede emitting original sub";
563
564
565 done_testing($tests);
566
567 __DATA__
568 # TODO [perl #120950] This succeeds when run a 2nd time
569 # y/uni/code/
570 tr/\x{345}/\x{370}/;
571 ####
572 # y/uni/code/  [perl #120950] This 2nd instance succeeds
573 tr/\x{345}/\x{370}/;
574 ####
575 # A constant
576 1;
577 ####
578 # Constants in a block
579 # CONTEXT no warnings;
580 {
581     '???';
582     2;
583 }
584 ####
585 # List of constants in void context
586 # CONTEXT no warnings;
587 (1,2,3);
588 0;
589 >>>>
590 '???', '???', '???';
591 0;
592 ####
593 # Lexical and simple arithmetic
594 my $test;
595 ++$test and $test /= 2;
596 >>>>
597 my $test;
598 $test /= 2 if ++$test;
599 ####
600 # list x
601 -((1, 2) x 2);
602 ####
603 # Assignment to list x
604 ((undef) x 3) = undef;
605 ####
606 # lvalue sub
607 {
608     my $test = sub : lvalue {
609         my $x;
610     }
611     ;
612 }
613 ####
614 # method
615 {
616     my $test = sub : method {
617         my $x;
618     }
619     ;
620 }
621 ####
622 # anonsub attrs at statement start
623 my $x = do { +sub : lvalue { my $y; } };
624 my $z = do { foo: +sub : method { my $a; } };
625 ####
626 # block with continue
627 {
628     234;
629 }
630 continue {
631     123;
632 }
633 ####
634 # lexical and package scalars
635 my $x;
636 print $main::x;
637 ####
638 # lexical and package arrays
639 my @x;
640 print $main::x[1];
641 print \my @a;
642 ####
643 # lexical and package hashes
644 my %x;
645 $x{warn()};
646 ####
647 # our (LIST)
648 our($foo, $bar, $baz);
649 ####
650 # CONTEXT { package Dog } use feature "state";
651 # variables with declared classes
652 my Dog $spot;
653 our Dog $spotty;
654 state Dog $spotted;
655 my Dog @spot;
656 our Dog @spotty;
657 state Dog @spotted;
658 my Dog %spot;
659 our Dog %spotty;
660 state Dog %spotted;
661 my Dog ($foo, @bar, %baz);
662 our Dog ($phoo, @barr, %bazz);
663 state Dog ($fough, @barre, %bazze);
664 ####
665 # local our
666 local our $rhubarb;
667 local our($rhu, $barb);
668 ####
669 # <>
670 my $foo;
671 $_ .= <> . <ARGV> . <$foo>;
672 <$foo>;
673 <${foo}>;
674 <$ foo>;
675 >>>>
676 my $foo;
677 $_ .= readline(ARGV) . readline(ARGV) . readline($foo);
678 readline $foo;
679 glob $foo;
680 glob $foo;
681 ####
682 # readline
683 readline 'FH';
684 readline *$_;
685 readline *{$_};
686 readline ${"a"};
687 >>>>
688 readline 'FH';
689 readline *$_;
690 readline *{$_;};
691 readline ${'a';};
692 ####
693 # <<>>
694 $_ = <<>>;
695 ####
696 # \x{}
697 my $foo = "Ab\x{100}\200\x{200}\237Cd\000Ef\x{1000}\cA\x{2000}\cZ";
698 my $bar = "\x{100}";
699 ####
700 # Latin-1 chars
701 # TODO ? ord("A") != 65 && "EBCDIC"
702 my $baz = "B\366\x{100}";
703 my $bba = qr/B\366\x{100}/;
704 ####
705 # s///e
706 s/x/'y';/e;
707 s/x/$a;/e;
708 s/x/complex_expression();/e;
709 ####
710 # block
711 { my $x; }
712 ####
713 # while 1
714 while (1) { my $k; }
715 ####
716 # trailing for
717 my ($x,@a);
718 $x=1 for @a;
719 >>>>
720 my($x, @a);
721 $x = 1 foreach (@a);
722 ####
723 # 2 arguments in a 3 argument for
724 for (my $i = 0; $i < 2;) {
725     my $z = 1;
726 }
727 ####
728 # 3 argument for
729 for (my $i = 0; $i < 2; ++$i) {
730     my $z = 1;
731 }
732 ####
733 # 3 argument for again
734 for (my $i = 0; $i < 2; ++$i) {
735     my $z = 1;
736 }
737 ####
738 # 3-argument for with inverted condition
739 for (my $i; not $i;) {
740     die;
741 }
742 for (my $i; not $i; ++$i) {
743     die;
744 }
745 for (my $a; not +($1 || 2) ** 2;) {
746     die;
747 }
748 Something_to_put_the_loop_in_void_context();
749 ####
750 # while/continue
751 my $i;
752 while ($i) { my $z = 1; } continue { $i = 99; }
753 ####
754 # foreach with my
755 foreach my $i (1, 2) {
756     my $z = 1;
757 }
758 ####
759 # OPTIONS -p
760 # foreach with my under -p
761 foreach my $i (1) {
762     die;
763 }
764 ####
765 # foreach
766 my $i;
767 foreach $i (1, 2) {
768     my $z = 1;
769 }
770 ####
771 # foreach, 2 mys
772 my $i;
773 foreach my $i (1, 2) {
774     my $z = 1;
775 }
776 ####
777 # foreach with our
778 foreach our $i (1, 2) {
779     my $z = 1;
780 }
781 ####
782 # foreach with my and our
783 my $i;
784 foreach our $i (1, 2) {
785     my $z = 1;
786 }
787 ####
788 # foreach with state
789 # CONTEXT use feature "state";
790 foreach state $i (1, 2) {
791     state $z = 1;
792 }
793 ####
794 # foreach with sub call
795 foreach $_ (hcaerof()) {
796     ();
797 }
798 ####
799 # reverse sort
800 my @x;
801 print reverse sort(@x);
802 ####
803 # sort with cmp
804 my @x;
805 print((sort {$b cmp $a} @x));
806 ####
807 # reverse sort with block
808 my @x;
809 print((reverse sort {$b <=> $a} @x));
810 ####
811 # foreach reverse
812 our @a;
813 print $_ foreach (reverse @a);
814 ####
815 # foreach reverse (not inplace)
816 our @a;
817 print $_ foreach (reverse 1, 2..5);
818 ####
819 # bug #38684
820 our @ary;
821 @ary = split(' ', 'foo', 0);
822 ####
823 my @ary;
824 @ary = split(' ', 'foo', 0);
825 ####
826 # Split to our array
827 our @array = split(//, 'foo', 0);
828 ####
829 # Split to my array
830 my @array  = split(//, 'foo', 0);
831 ####
832 our @array;
833 my $c;
834 @array = split(/x(?{ $c++; })y/, 'foo', 0);
835 ####
836 my($x, $y, $p);
837 our $c;
838 ($x, $y) = split(/$p(?{ $c++; })y/, 'foo', 2);
839 ####
840 our @ary;
841 my $pat;
842 @ary = split(/$pat/, 'foo', 0);
843 ####
844 my @ary;
845 our $pat;
846 @ary = split(/$pat/, 'foo', 0);
847 ####
848 our @array;
849 my $pat;
850 local @array = split(/$pat/, 'foo', 0);
851 ####
852 our $pat;
853 my @array  = split(/$pat/, 'foo', 0);
854 ####
855 # bug #40055
856 do { () }; 
857 ####
858 # bug #40055
859 do { my $x = 1; $x }; 
860 ####
861 # <20061012113037.GJ25805@c4.convolution.nl>
862 my $f = sub {
863     +{[]};
864 } ;
865 ####
866 # bug #43010
867 '!@$%'->();
868 ####
869 # bug #43010
870 ::();
871 ####
872 # bug #43010
873 '::::'->();
874 ####
875 # bug #43010
876 &::::;
877 ####
878 # [perl #77172]
879 package rt77172;
880 sub foo {} foo & & & foo;
881 >>>>
882 package rt77172;
883 foo(&{&} & foo());
884 ####
885 # variables as method names
886 my $bar;
887 'Foo'->$bar('orz');
888 'Foo'->$bar('orz') = 'a stranger stranger than before';
889 ####
890 # constants as method names
891 'Foo'->bar('orz');
892 ####
893 # constants as method names without ()
894 'Foo'->bar;
895 ####
896 # [perl #47359] "indirect" method call notation
897 our @bar;
898 foo{@bar}+1,->foo;
899 (foo{@bar}+1),foo();
900 foo{@bar}1 xor foo();
901 >>>>
902 our @bar;
903 (foo { @bar } 1)->foo;
904 (foo { @bar } 1), foo();
905 foo { @bar } 1 xor foo();
906 ####
907 # indirops with blocks
908 # CONTEXT use 5.01;
909 print {*STDOUT;} 'foo';
910 printf {*STDOUT;} 'foo';
911 say {*STDOUT;} 'foo';
912 system {'foo';} '-foo';
913 exec {'foo';} '-foo';
914 ####
915 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
916 # CONTEXT use feature ':5.10';
917 # say
918 say 'foo';
919 ####
920 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
921 # CONTEXT use 5.10.0;
922 # say in the context of use 5.10.0
923 say 'foo';
924 ####
925 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
926 # say with use 5.10.0
927 use 5.10.0;
928 say 'foo';
929 >>>>
930 no feature ':all';
931 use feature ':5.10';
932 say 'foo';
933 ####
934 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
935 # say with use feature ':5.10';
936 use feature ':5.10';
937 say 'foo';
938 >>>>
939 use feature 'say', 'state', 'switch';
940 say 'foo';
941 ####
942 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
943 # CONTEXT use feature ':5.10';
944 # say with use 5.10.0 in the context of use feature
945 use 5.10.0;
946 say 'foo';
947 >>>>
948 no feature ':all';
949 use feature ':5.10';
950 say 'foo';
951 ####
952 # SKIP ?$] < 5.010 && "say not implemented on this Perl version"
953 # CONTEXT use 5.10.0;
954 # say with use feature ':5.10' in the context of use 5.10.0
955 use feature ':5.10';
956 say 'foo';
957 >>>>
958 say 'foo';
959 ####
960 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
961 # CONTEXT use feature ':5.15';
962 # __SUB__
963 __SUB__;
964 ####
965 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
966 # CONTEXT use 5.15.0;
967 # __SUB__ in the context of use 5.15.0
968 __SUB__;
969 ####
970 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
971 # __SUB__ with use 5.15.0
972 use 5.15.0;
973 __SUB__;
974 >>>>
975 no feature ':all';
976 use feature ':5.16';
977 __SUB__;
978 ####
979 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
980 # __SUB__ with use feature ':5.15';
981 use feature ':5.15';
982 __SUB__;
983 >>>>
984 use feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval';
985 __SUB__;
986 ####
987 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
988 # CONTEXT use feature ':5.15';
989 # __SUB__ with use 5.15.0 in the context of use feature
990 use 5.15.0;
991 __SUB__;
992 >>>>
993 no feature ':all';
994 use feature ':5.16';
995 __SUB__;
996 ####
997 # SKIP ?$] < 5.015 && "__SUB__ not implemented on this Perl version"
998 # CONTEXT use 5.15.0;
999 # __SUB__ with use feature ':5.15' in the context of use 5.15.0
1000 use feature ':5.15';
1001 __SUB__;
1002 >>>>
1003 __SUB__;
1004 ####
1005 # SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
1006 # CONTEXT use feature ':5.10';
1007 # state vars
1008 state $x = 42;
1009 ####
1010 # SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
1011 # CONTEXT use feature ':5.10';
1012 # state var assignment
1013 {
1014     my $y = (state $x = 42);
1015 }
1016 ####
1017 # SKIP ?$] < 5.010 && "state vars not implemented on this Perl version"
1018 # CONTEXT use feature ':5.10';
1019 # state vars in anonymous subroutines
1020 $a = sub {
1021     state $x;
1022     return $x++;
1023 }
1024 ;
1025 ####
1026 # SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
1027 # each @array;
1028 each @ARGV;
1029 each @$a;
1030 ####
1031 # SKIP ?$] < 5.011 && 'each @array not implemented on this Perl version'
1032 # keys @array; values @array
1033 keys @$a if keys @ARGV;
1034 values @ARGV if values @$a;
1035 ####
1036 # Anonymous arrays and hashes, and references to them
1037 my $a = {};
1038 my $b = \{};
1039 my $c = [];
1040 my $d = \[];
1041 ####
1042 # SKIP ?$] < 5.010 && "smartmatch and given/whereso not implemented on this Perl version"
1043 # CONTEXT use feature ':5.10'; no warnings 'experimental::smartmatch';
1044 # implicit smartmatch in given/whereso
1045 given ('foo') {
1046     whereso ('bar') { continue; }
1047     whereso ($_ == 3) { continue; }
1048     whereis ('quux') { continue; }
1049     0;
1050 }
1051 ####
1052 # conditions in elsifs (regression in change #33710 which fixed bug #37302)
1053 if ($a) { x(); }
1054 elsif ($b) { x(); }
1055 elsif ($a and $b) { x(); }
1056 elsif ($a or $b) { x(); }
1057 else { x(); }
1058 ####
1059 # interpolation in regexps
1060 my($y, $t);
1061 /x${y}z$t/;
1062 ####
1063 # TODO new undocumented cpan-bug #33708
1064 # cpan-bug #33708
1065 %{$_ || {}}
1066 ####
1067 # TODO hash constants not yet fixed
1068 # cpan-bug #33708
1069 use constant H => { "#" => 1 }; H->{"#"}
1070 ####
1071 # TODO optimized away 0 not yet fixed
1072 # cpan-bug #33708
1073 foreach my $i (@_) { 0 }
1074 ####
1075 # tests with not, not optimized
1076 my $c;
1077 x() unless $a;
1078 x() if not $a and $b;
1079 x() if $a and not $b;
1080 x() unless not $a and $b;
1081 x() unless $a and not $b;
1082 x() if not $a or $b;
1083 x() if $a or not $b;
1084 x() unless not $a or $b;
1085 x() unless $a or not $b;
1086 x() if $a and not $b and $c;
1087 x() if not $a and $b and not $c;
1088 x() unless $a and not $b and $c;
1089 x() unless not $a and $b and not $c;
1090 x() if $a or not $b or $c;
1091 x() if not $a or $b or not $c;
1092 x() unless $a or not $b or $c;
1093 x() unless not $a or $b or not $c;
1094 ####
1095 # tests with not, optimized
1096 my $c;
1097 x() if not $a;
1098 x() unless not $a;
1099 x() if not $a and not $b;
1100 x() unless not $a and not $b;
1101 x() if not $a or not $b;
1102 x() unless not $a or not $b;
1103 x() if not $a and not $b and $c;
1104 x() unless not $a and not $b and $c;
1105 x() if not $a or not $b or $c;
1106 x() unless not $a or not $b or $c;
1107 x() if not $a and not $b and not $c;
1108 x() unless not $a and not $b and not $c;
1109 x() if not $a or not $b or not $c;
1110 x() unless not $a or not $b or not $c;
1111 x() unless not $a or not $b or not $c;
1112 >>>>
1113 my $c;
1114 x() unless $a;
1115 x() if $a;
1116 x() unless $a or $b;
1117 x() if $a or $b;
1118 x() unless $a and $b;
1119 x() if $a and $b;
1120 x() if not $a || $b and $c;
1121 x() unless not $a || $b and $c;
1122 x() if not $a && $b or $c;
1123 x() unless not $a && $b or $c;
1124 x() unless $a or $b or $c;
1125 x() if $a or $b or $c;
1126 x() unless $a and $b and $c;
1127 x() if $a and $b and $c;
1128 x() unless not $a && $b && $c;
1129 ####
1130 # tests that should be constant folded
1131 x() if 1;
1132 x() if GLIPP;
1133 x() if !GLIPP;
1134 x() if GLIPP && GLIPP;
1135 x() if !GLIPP || GLIPP;
1136 x() if do { GLIPP };
1137 x() if do { no warnings 'void'; 5; GLIPP };
1138 x() if do { !GLIPP };
1139 if (GLIPP) { x() } else { z() }
1140 if (!GLIPP) { x() } else { z() }
1141 if (GLIPP) { x() } elsif (GLIPP) { z() }
1142 if (!GLIPP) { x() } elsif (GLIPP) { z() }
1143 if (GLIPP) { x() } elsif (!GLIPP) { z() }
1144 if (!GLIPP) { x() } elsif (!GLIPP) { z() }
1145 if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (GLIPP) { t() }
1146 if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
1147 if (!GLIPP) { x() } elsif (!GLIPP) { z() } elsif (!GLIPP) { t() }
1148 >>>>
1149 x();
1150 x();
1151 '???';
1152 x();
1153 x();
1154 x();
1155 x();
1156 do {
1157     '???'
1158 };
1159 do {
1160     x()
1161 };
1162 do {
1163     z()
1164 };
1165 do {
1166     x()
1167 };
1168 do {
1169     z()
1170 };
1171 do {
1172     x()
1173 };
1174 '???';
1175 do {
1176     t()
1177 };
1178 '???';
1179 !1;
1180 ####
1181 # TODO constant deparsing has been backed out for 5.12
1182 # XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
1183 # tests that shouldn't be constant folded
1184 # It might be fundamentally impossible to make this work on ithreads, in which
1185 # case the TODO should become a SKIP
1186 x() if $a;
1187 if ($a == 1) { x() } elsif ($b == 2) { z() }
1188 if (do { foo(); GLIPP }) { x() }
1189 if (do { $a++; GLIPP }) { x() }
1190 >>>>
1191 x() if $a;
1192 if ($a == 1) { x(); } elsif ($b == 2) { z(); }
1193 if (do { foo(); GLIPP }) { x(); }
1194 if (do { ++$a; GLIPP }) { x(); }
1195 ####
1196 # TODO constant deparsing has been backed out for 5.12
1197 # tests for deparsing constants
1198 warn PI;
1199 ####
1200 # TODO constant deparsing has been backed out for 5.12
1201 # tests for deparsing imported constants
1202 warn O_TRUNC;
1203 ####
1204 # TODO constant deparsing has been backed out for 5.12
1205 # tests for deparsing re-exported constants
1206 warn O_CREAT;
1207 ####
1208 # TODO constant deparsing has been backed out for 5.12
1209 # tests for deparsing imported constants that got deleted from the original namespace
1210 warn O_APPEND;
1211 ####
1212 # TODO constant deparsing has been backed out for 5.12
1213 # XXXTODO ? $Config::Config{useithreads} && "doesn't work with threads"
1214 # tests for deparsing constants which got turned into full typeglobs
1215 # It might be fundamentally impossible to make this work on ithreads, in which
1216 # case the TODO should become a SKIP
1217 warn O_EXCL;
1218 eval '@Fcntl::O_EXCL = qw/affe tiger/;';
1219 warn O_EXCL;
1220 ####
1221 # TODO constant deparsing has been backed out for 5.12
1222 # tests for deparsing of blessed constant with overloaded numification
1223 warn OVERLOADED_NUMIFICATION;
1224 ####
1225 # strict
1226 no strict;
1227 print $x;
1228 use strict 'vars';
1229 print $main::x;
1230 use strict 'subs';
1231 print $main::x;
1232 use strict 'refs';
1233 print $main::x;
1234 no strict 'vars';
1235 $x;
1236 ####
1237 # TODO Subsets of warnings could be encoded textually, rather than as bitflips.
1238 # subsets of warnings
1239 no warnings 'deprecated';
1240 my $x;
1241 ####
1242 # TODO Better test for CPAN #33708 - the deparsed code has different behaviour
1243 # CPAN #33708
1244 use strict;
1245 no warnings;
1246
1247 foreach (0..3) {
1248     my $x = 2;
1249     {
1250         my $x if 0;
1251         print ++$x, "\n";
1252     }
1253 }
1254 ####
1255 # no attribute list
1256 my $pi = 4;
1257 ####
1258 # SKIP ?$] > 5.013006 && ":= is now a syntax error"
1259 # := treated as an empty attribute list
1260 no warnings;
1261 my $pi := 4;
1262 >>>>
1263 no warnings;
1264 my $pi = 4;
1265 ####
1266 # : = empty attribute list
1267 my $pi : = 4;
1268 >>>>
1269 my $pi = 4;
1270 ####
1271 # in place sort
1272 our @a;
1273 my @b;
1274 @a = sort @a;
1275 @b = sort @b;
1276 ();
1277 ####
1278 # in place reverse
1279 our @a;
1280 my @b;
1281 @a = reverse @a;
1282 @b = reverse @b;
1283 ();
1284 ####
1285 # #71870 Use of uninitialized value in bitwise and B::Deparse
1286 my($r, $s, @a);
1287 @a = split(/foo/, $s, 0);
1288 $r = qr/foo/;
1289 @a = split(/$r/, $s, 0);
1290 ();
1291 ####
1292 # package declaration before label
1293 {
1294     package Foo;
1295     label: print 123;
1296 }
1297 ####
1298 # shift optimisation
1299 shift;
1300 >>>>
1301 shift();
1302 ####
1303 # shift optimisation
1304 shift @_;
1305 ####
1306 # shift optimisation
1307 pop;
1308 >>>>
1309 pop();
1310 ####
1311 # shift optimisation
1312 pop @_;
1313 ####
1314 #[perl #20444]
1315 "foo" =~ (1 ? /foo/ : /bar/);
1316 "foo" =~ (1 ? y/foo// : /bar/);
1317 "foo" =~ (1 ? y/foo//r : /bar/);
1318 "foo" =~ (1 ? s/foo// : /bar/);
1319 >>>>
1320 'foo' =~ ($_ =~ /foo/);
1321 'foo' =~ ($_ =~ tr/fo//);
1322 'foo' =~ ($_ =~ tr/fo//r);
1323 'foo' =~ ($_ =~ s/foo//);
1324 ####
1325 # The fix for [perl #20444] broke this.
1326 'foo' =~ do { () };
1327 ####
1328 # [perl #81424] match against aelemfast_lex
1329 my @s;
1330 print /$s[1]/;
1331 ####
1332 # /$#a/
1333 print /$#main::a/;
1334 ####
1335 # /@array/
1336 our @a;
1337 my @b;
1338 print /@a/;
1339 print /@b/;
1340 print qr/@a/;
1341 print qr/@b/;
1342 ####
1343 # =~ QR_CONSTANT
1344 use constant QR_CONSTANT => qr/a/soupmix;
1345 '' =~ QR_CONSTANT;
1346 >>>>
1347 '' =~ /a/impsux;
1348 ####
1349 # $lexical =~ //
1350 my $x;
1351 $x =~ //;
1352 ####
1353 # [perl #91318] /regexp/applaud
1354 print /a/a, s/b/c/a;
1355 print /a/aa, s/b/c/aa;
1356 print /a/p, s/b/c/p;
1357 print /a/l, s/b/c/l;
1358 print /a/u, s/b/c/u;
1359 {
1360     use feature "unicode_strings";
1361     print /a/d, s/b/c/d;
1362 }
1363 {
1364     use re "/u";
1365     print /a/d, s/b/c/d;
1366 }
1367 {
1368     use 5.012;
1369     print /a/d, s/b/c/d;
1370 }
1371 >>>>
1372 print /a/a, s/b/c/a;
1373 print /a/aa, s/b/c/aa;
1374 print /a/p, s/b/c/p;
1375 print /a/l, s/b/c/l;
1376 print /a/u, s/b/c/u;
1377 {
1378     use feature 'unicode_strings';
1379     print /a/d, s/b/c/d;
1380 }
1381 {
1382     BEGIN { $^H{'reflags'}         = '0';
1383             $^H{'reflags_charset'} = '2'; }
1384     print /a/d, s/b/c/d;
1385 }
1386 {
1387     no feature ':all';
1388     use feature ':5.12';
1389     print /a/d, s/b/c/d;
1390 }
1391 ####
1392 # all the flags (qr//)
1393 $_ = qr/X/m;
1394 $_ = qr/X/s;
1395 $_ = qr/X/i;
1396 $_ = qr/X/x;
1397 $_ = qr/X/p;
1398 $_ = qr/X/o;
1399 $_ = qr/X/u;
1400 $_ = qr/X/a;
1401 $_ = qr/X/l;
1402 $_ = qr/X/n;
1403 ####
1404 use feature 'unicode_strings';
1405 $_ = qr/X/d;
1406 ####
1407 # all the flags (m//)
1408 /X/m;
1409 /X/s;
1410 /X/i;
1411 /X/x;
1412 /X/p;
1413 /X/o;
1414 /X/u;
1415 /X/a;
1416 /X/l;
1417 /X/n;
1418 /X/g;
1419 /X/cg;
1420 ####
1421 use feature 'unicode_strings';
1422 /X/d;
1423 ####
1424 # all the flags (s///)
1425 s/X//m;
1426 s/X//s;
1427 s/X//i;
1428 s/X//x;
1429 s/X//p;
1430 s/X//o;
1431 s/X//u;
1432 s/X//a;
1433 s/X//l;
1434 s/X//n;
1435 s/X//g;
1436 s/X/'';/e;
1437 s/X//r;
1438 ####
1439 use feature 'unicode_strings';
1440 s/X//d;
1441 ####
1442 # all the flags (tr///)
1443 tr/X/Y/c;
1444 tr/X//d;
1445 tr/X//s;
1446 tr/X//r;
1447 ####
1448 # [perl #119807] s//\(3)/ge should not warn when deparsed (\3 warns)
1449 s/foo/\(3);/eg;
1450 ####
1451 # [perl #115256]
1452 "" =~ /a(?{ print q|
1453 |})/;
1454 >>>>
1455 '' =~ /a(?{ print "\n"; })/;
1456 ####
1457 # [perl #123217]
1458 $_ = qr/(??{<<END})/
1459 f.o
1460 b.r
1461 END
1462 >>>>
1463 $_ = qr/(??{ "f.o\nb.r\n"; })/;
1464 ####
1465 # More regexp code block madness
1466 my($b, @a);
1467 /(?{ die $b; })/;
1468 /a(?{ die $b; })a/;
1469 /$a(?{ die $b; })/;
1470 /@a(?{ die $b; })/;
1471 /(??{ die $b; })/;
1472 /a(??{ die $b; })a/;
1473 /$a(??{ die $b; })/;
1474 /@a(??{ die $b; })/;
1475 qr/(?{ die $b; })/;
1476 qr/a(?{ die $b; })a/;
1477 qr/$a(?{ die $b; })/;
1478 qr/@a(?{ die $b; })/;
1479 qr/(??{ die $b; })/;
1480 qr/a(??{ die $b; })a/;
1481 qr/$a(??{ die $b; })/;
1482 qr/@a(??{ die $b; })/;
1483 s/(?{ die $b; })//;
1484 s/a(?{ die $b; })a//;
1485 s/$a(?{ die $b; })//;
1486 s/@a(?{ die $b; })//;
1487 s/(??{ die $b; })//;
1488 s/a(??{ die $b; })a//;
1489 s/$a(??{ die $b; })//;
1490 s/@a(??{ die $b; })//;
1491 ####
1492 # /(?x)<newline><tab>/
1493 /(?x)
1494         /;
1495 ####
1496 # y///r
1497 tr/a/b/r + $a =~ tr/p/q/r;
1498 ####
1499 # y///d in list [perl #119815]
1500 () = tr/a//d;
1501 ####
1502 # [perl #90898]
1503 <a,>;
1504 glob 'a,';
1505 >>>>
1506 glob 'a,';
1507 glob 'a,';
1508 ####
1509 # [perl #91008]
1510 # SKIP ?$] >= 5.023 && "autoderef deleted in this Perl version"
1511 # CONTEXT no warnings 'experimental::autoderef';
1512 each $@;
1513 keys $~;
1514 values $!;
1515 ####
1516 # readpipe with complex expression
1517 readpipe $a + $b;
1518 ####
1519 # aelemfast
1520 $b::a[0] = 1;
1521 ####
1522 # aelemfast for a lexical
1523 my @a;
1524 $a[0] = 1;
1525 ####
1526 # feature features without feature
1527 # CONTEXT no warnings 'experimental::smartmatch';
1528 CORE::state $x;
1529 CORE::say $x;
1530 CORE::given ($x) {
1531     CORE::whereso (3) {
1532         continue;
1533     }
1534     CORE::whereis (5) {
1535         continue;
1536     }
1537     next;
1538 }
1539 CORE::evalbytes '';
1540 () = CORE::__SUB__;
1541 () = CORE::fc $x;
1542 ####
1543 # feature features when feature has been disabled by use VERSION
1544 # CONTEXT no warnings 'experimental::smartmatch';
1545 use feature (sprintf(":%vd", $^V));
1546 use 1;
1547 CORE::say $_;
1548 CORE::state $x;
1549 CORE::given ($x) {
1550     CORE::whereso (3) {
1551         continue;
1552     }
1553     CORE::whereis (5) {
1554         continue;
1555     }
1556     next;
1557 }
1558 CORE::evalbytes '';
1559 () = CORE::__SUB__;
1560 >>>>
1561 CORE::say $_;
1562 CORE::state $x;
1563 CORE::given ($x) {
1564     CORE::whereso (3) {
1565         continue;
1566     }
1567     CORE::whereis (5) {
1568         continue;
1569     }
1570     next;
1571 }
1572 CORE::evalbytes '';
1573 () = CORE::__SUB__;
1574 ####
1575 # (the above test with CONTEXT, and the output is equivalent but different)
1576 # CONTEXT use feature ':5.10'; no warnings 'experimental::smartmatch';
1577 # feature features when feature has been disabled by use VERSION
1578 use feature (sprintf(":%vd", $^V));
1579 use 1;
1580 CORE::say $_;
1581 CORE::state $x;
1582 CORE::given ($x) {
1583     CORE::whereso (3) {
1584         continue;
1585     }
1586     CORE::whereis (5) {
1587         continue;
1588     }
1589     next;
1590 }
1591 CORE::evalbytes '';
1592 () = CORE::__SUB__;
1593 >>>>
1594 no feature ':all';
1595 use feature ':default';
1596 CORE::say $_;
1597 CORE::state $x;
1598 CORE::given ($x) {
1599     CORE::whereso (3) {
1600         continue;
1601     }
1602     CORE::whereis (5) {
1603         continue;
1604     }
1605     next;
1606 }
1607 CORE::evalbytes '';
1608 () = CORE::__SUB__;
1609 ####
1610 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
1611 # lexical subroutines and keywords of the same name
1612 # CONTEXT use feature 'lexical_subs', 'switch'; no warnings 'experimental';
1613 my sub else;
1614 my sub elsif;
1615 my sub for;
1616 my sub foreach;
1617 my sub given;
1618 my sub if;
1619 my sub m;
1620 my sub no;
1621 my sub package;
1622 my sub q;
1623 my sub qq;
1624 my sub qr;
1625 my sub qx;
1626 my sub require;
1627 my sub s;
1628 my sub sub;
1629 my sub tr;
1630 my sub unless;
1631 my sub until;
1632 my sub use;
1633 my sub whereis;
1634 my sub whereso;
1635 my sub while;
1636 CORE::if ($1) { die; }
1637 CORE::if ($1) { die; }
1638 CORE::elsif ($1) { die; }
1639 CORE::else { die; }
1640 CORE::for (die; $1; die) { die; }
1641 CORE::foreach $_ (1 .. 10) { die; }
1642 die CORE::foreach (1);
1643 CORE::given ($1) { die; }
1644 CORE::m[/];
1645 CORE::m?/?;
1646 CORE::package foo;
1647 CORE::no strict;
1648 () = (CORE::q['], CORE::qq["$_], CORE::qr//, CORE::qx[`]);
1649 CORE::require 1;
1650 CORE::s///;
1651 () = CORE::sub { die; } ;
1652 CORE::tr///;
1653 CORE::unless ($1) { die; }
1654 CORE::until ($1) { die; }
1655 die CORE::until $1;
1656 CORE::use strict;
1657 CORE::whereis (5) { die; }
1658 CORE::whereso ($1 ~~ $2) { die; }
1659 CORE::while ($1) { die; }
1660 die CORE::while $1;
1661 ####
1662 # Feature hints
1663 use feature 'current_sub', 'evalbytes';
1664 print;
1665 use 1;
1666 print;
1667 use 5.014;
1668 print;
1669 no feature 'unicode_strings';
1670 print;
1671 >>>>
1672 use feature 'current_sub', 'evalbytes';
1673 print $_;
1674 no feature ':all';
1675 use feature ':default';
1676 print $_;
1677 no feature ':all';
1678 use feature ':5.12';
1679 print $_;
1680 no feature 'unicode_strings';
1681 print $_;
1682 ####
1683 # $#- $#+ $#{%} etc.
1684 my @x;
1685 @x = ($#{`}, $#{~}, $#{!}, $#{@}, $#{$}, $#{%}, $#{^}, $#{&}, $#{*});
1686 @x = ($#{(}, $#{)}, $#{[}, $#{{}, $#{]}, $#{}}, $#{'}, $#{"}, $#{,});
1687 @x = ($#{<}, $#{.}, $#{>}, $#{/}, $#{?}, $#{=}, $#+, $#{\}, $#{|}, $#-);
1688 @x = ($#{;}, $#{:}, $#{1}), $#_;
1689 ####
1690 # ${#} interpolated
1691 # It's a known TODO that warnings are deparsed as bits, not textually.
1692 no warnings;
1693 () = "${#}a";
1694 ####
1695 # [perl #86060] $( $| $) in regexps need braces
1696 /${(}/;
1697 /${|}/;
1698 /${)}/;
1699 /${(}${|}${)}/;
1700 /@{+}@{-}/;
1701 ####
1702 # ()[...]
1703 my(@a) = ()[()];
1704 ####
1705 # sort(foo(bar))
1706 # sort(foo(bar)) is interpreted as sort &foo(bar)
1707 # sort foo(bar) is interpreted as sort foo bar
1708 # parentheses are not optional in this case
1709 print sort(foo('bar'));
1710 >>>>
1711 print sort(foo('bar'));
1712 ####
1713 # substr assignment
1714 substr(my $a, 0, 0) = (foo(), bar());
1715 $a++;
1716 ####
1717 # This following line works around an unfixed bug that we are not trying to 
1718 # test for here:
1719 # CONTEXT BEGIN { $^H{a} = "b"; delete $^H{a} } # make %^H localised
1720 # hint hash
1721 BEGIN { $^H{'foo'} = undef; }
1722 {
1723  BEGIN { $^H{'bar'} = undef; }
1724  {
1725   BEGIN { $^H{'baz'} = undef; }
1726   {
1727    print $_;
1728   }
1729   print $_;
1730  }
1731  print $_;
1732 }
1733 BEGIN { $^H{q[']} = '('; }
1734 print $_;
1735 ####
1736 # This following line works around an unfixed bug that we are not trying to 
1737 # test for here:
1738 # CONTEXT BEGIN { $^H{a} = "b"; delete $^H{a} } # make %^H localised
1739 # hint hash changes that serialise the same way with sort %hh
1740 BEGIN { $^H{'a'} = 'b'; }
1741 {
1742  BEGIN { $^H{'b'} = 'a'; delete $^H{'a'}; }
1743  print $_;
1744 }
1745 print $_;
1746 ####
1747 # [perl #47361] do({}) and do +{} (variants of do-file)
1748 do({});
1749 do +{};
1750 sub foo::do {}
1751 package foo;
1752 CORE::do({});
1753 CORE::do +{};
1754 >>>>
1755 do({});
1756 do({});
1757 package foo;
1758 CORE::do({});
1759 CORE::do({});
1760 ####
1761 # [perl #77096] functions that do not follow the llafr
1762 () = (return 1) + time;
1763 () = (return ($1 + $2) * $3) + time;
1764 () = (return ($a xor $b)) + time;
1765 () = (do 'file') + time;
1766 () = (do ($1 + $2) * $3) + time;
1767 () = (do ($1 xor $2)) + time;
1768 () = (goto 1) + 3;
1769 () = (require 'foo') + 3;
1770 () = (require foo) + 3;
1771 () = (CORE::dump 1) + 3;
1772 () = (last 1) + 3;
1773 () = (next 1) + 3;
1774 () = (redo 1) + 3;
1775 () = (-R $_) + 3;
1776 () = (-W $_) + 3;
1777 () = (-X $_) + 3;
1778 () = (-r $_) + 3;
1779 () = (-w $_) + 3;
1780 () = (-x $_) + 3;
1781 ####
1782 # require(foo()) and do(foo())
1783 require (foo());
1784 do (foo());
1785 goto (foo());
1786 CORE::dump (foo());
1787 last (foo());
1788 next (foo());
1789 redo (foo());
1790 ####
1791 # require vstring
1792 require v5.16;
1793 ####
1794 # [perl #97476] not() *does* follow the llafr
1795 $_ = ($a xor not +($1 || 2) ** 2);
1796 ####
1797 # Precedence conundrums with argument-less function calls
1798 () = (eof) + 1;
1799 () = (return) + 1;
1800 () = (return, 1);
1801 () = warn;
1802 () = warn() + 1;
1803 () = setpgrp() + 1;
1804 ####
1805 # loopexes have assignment prec
1806 () = (CORE::dump a) | 'b';
1807 () = (goto a) | 'b';
1808 () = (last a) | 'b';
1809 () = (next a) | 'b';
1810 () = (redo a) | 'b';
1811 ####
1812 # [perl #63558] open local(*FH)
1813 open local *FH;
1814 pipe local *FH, local *FH;
1815 ####
1816 # [perl #91416] open "string"
1817 open 'open';
1818 open '####';
1819 open '^A';
1820 open "\ca";
1821 >>>>
1822 open *open;
1823 open '####';
1824 open '^A';
1825 open *^A;
1826 ####
1827 # "string"->[] ->{}
1828 no strict 'vars';
1829 () = 'open'->[0]; #aelemfast
1830 () = '####'->[0];
1831 () = '^A'->[0];
1832 () = "\ca"->[0];
1833 () = 'a::]b'->[0];
1834 () = 'open'->[$_]; #aelem
1835 () = '####'->[$_];
1836 () = '^A'->[$_];
1837 () = "\ca"->[$_];
1838 () = 'a::]b'->[$_];
1839 () = 'open'->{0}; #helem
1840 () = '####'->{0};
1841 () = '^A'->{0};
1842 () = "\ca"->{0};
1843 () = 'a::]b'->{0};
1844 >>>>
1845 no strict 'vars';
1846 () = $open[0];
1847 () = '####'->[0];
1848 () = '^A'->[0];
1849 () = $^A[0];
1850 () = 'a::]b'->[0];
1851 () = $open[$_];
1852 () = '####'->[$_];
1853 () = '^A'->[$_];
1854 () = $^A[$_];
1855 () = 'a::]b'->[$_];
1856 () = $open{'0'};
1857 () = '####'->{'0'};
1858 () = '^A'->{'0'};
1859 () = $^A{'0'};
1860 () = 'a::]b'->{'0'};
1861 ####
1862 # [perl #74740] -(f()) vs -f()
1863 $_ = -(f());
1864 ####
1865 # require <binop>
1866 require 'a' . $1;
1867 ####
1868 #[perl #30504] foreach-my postfix/prefix difference
1869 $_ = 'foo' foreach my ($foo1, $bar1, $baz1);
1870 foreach (my ($foo2, $bar2, $baz2)) { $_ = 'foo' }
1871 foreach my $i (my ($foo3, $bar3, $baz3)) { $i = 'foo' }
1872 >>>>
1873 $_ = 'foo' foreach (my($foo1, $bar1, $baz1));
1874 foreach $_ (my($foo2, $bar2, $baz2)) {
1875     $_ = 'foo';
1876 }
1877 foreach my $i (my($foo3, $bar3, $baz3)) {
1878     $i = 'foo';
1879 }
1880 ####
1881 #[perl #108224] foreach with continue block
1882 foreach (1 .. 3) { print } continue { print "\n" }
1883 foreach (1 .. 3) { } continue { }
1884 foreach my $i (1 .. 3) { print $i } continue { print "\n" }
1885 foreach my $i (1 .. 3) { } continue { }
1886 >>>>
1887 foreach $_ (1 .. 3) {
1888     print $_;
1889 }
1890 continue {
1891     print "\n";
1892 }
1893 foreach $_ (1 .. 3) {
1894     ();
1895 }
1896 continue {
1897     ();
1898 }
1899 foreach my $i (1 .. 3) {
1900     print $i;
1901 }
1902 continue {
1903     print "\n";
1904 }
1905 foreach my $i (1 .. 3) {
1906     ();
1907 }
1908 continue {
1909     ();
1910 }
1911 ####
1912 # file handles
1913 no strict;
1914 my $mfh;
1915 open F;
1916 open *F;
1917 open $fh;
1918 open $mfh;
1919 open 'a+b';
1920 select *F;
1921 select F;
1922 select $f;
1923 select $mfh;
1924 select 'a+b';
1925 ####
1926 # 'my' works with padrange op
1927 my($z, @z);
1928 my $m1;
1929 $m1 = 1;
1930 $z = $m1;
1931 my $m2 = 2;
1932 my($m3, $m4);
1933 ($m3, $m4) = (1, 2);
1934 @z = ($m3, $m4);
1935 my($m5, $m6) = (1, 2);
1936 my($m7, undef, $m8) = (1, 2, 3);
1937 @z = ($m7, undef, $m8);
1938 ($m7, undef, $m8) = (1, 2, 3);
1939 ####
1940 # 'our/local' works with padrange op
1941 our($z, @z);
1942 our $o1;
1943 no strict;
1944 local $o11;
1945 $o1 = 1;
1946 local $o1 = 1;
1947 $z = $o1;
1948 $z = local $o1;
1949 our $o2 = 2;
1950 our($o3, $o4);
1951 ($o3, $o4) = (1, 2);
1952 local($o3, $o4) = (1, 2);
1953 @z = ($o3, $o4);
1954 @z = local($o3, $o4);
1955 our($o5, $o6) = (1, 2);
1956 our($o7, undef, $o8) = (1, 2, 3);
1957 @z = ($o7, undef, $o8);
1958 @z = local($o7, undef, $o8);
1959 ($o7, undef, $o8) = (1, 2, 3);
1960 local($o7, undef, $o8) = (1, 2, 3);
1961 ####
1962 # 'state' works with padrange op
1963 # CONTEXT no strict; use feature 'state';
1964 state($z, @z);
1965 state $s1;
1966 $s1 = 1;
1967 $z = $s1;
1968 state $s2 = 2;
1969 state($s3, $s4);
1970 ($s3, $s4) = (1, 2);
1971 @z = ($s3, $s4);
1972 # assignment of state lists isn't implemented yet
1973 #state($s5, $s6) = (1, 2);
1974 #state($s7, undef, $s8) = (1, 2, 3);
1975 #@z = ($s7, undef, $s8);
1976 ($s7, undef, $s8) = (1, 2, 3);
1977 ####
1978 # anon arrays with padrange
1979 my($a, $b);
1980 my $c = [$a, $b];
1981 my $d = {$a, $b};
1982 ####
1983 # slices with padrange
1984 my($a, $b);
1985 my(@x, %y);
1986 @x = @x[$a, $b];
1987 @x = @y{$a, $b};
1988 ####
1989 # binops with padrange
1990 my($a, $b, $c);
1991 $c = $a cmp $b;
1992 $c = $a + $b;
1993 $a += $b;
1994 $c = $a - $b;
1995 $a -= $b;
1996 $c = my $a1 cmp $b;
1997 $c = my $a2 + $b;
1998 $a += my $b1;
1999 $c = my $a3 - $b;
2000 $a -= my $b2;
2001 ####
2002 # 'x' with padrange
2003 my($a, $b, $c, $d, @e);
2004 $c = $a x $b;
2005 $a x= $b;
2006 @e = ($a) x $d;
2007 @e = ($a, $b) x $d;
2008 @e = ($a, $b, $c) x $d;
2009 @e = ($a, 1) x $d;
2010 ####
2011 # @_ with padrange
2012 my($a, $b, $c) = @_;
2013 ####
2014 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
2015 # lexical subroutine
2016 # CONTEXT use feature 'lexical_subs';
2017 no warnings "experimental::lexical_subs";
2018 my sub f {}
2019 print f();
2020 >>>>
2021 BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x55"}
2022 my sub f {
2023     
2024 }
2025 print f();
2026 ####
2027 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
2028 # lexical "state" subroutine
2029 # CONTEXT use feature 'state', 'lexical_subs';
2030 no warnings 'experimental::lexical_subs';
2031 state sub f {}
2032 print f();
2033 >>>>
2034 BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x55"}
2035 state sub f {
2036     
2037 }
2038 print f();
2039 ####
2040 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
2041 # lexical subroutine scoping
2042 # CONTEXT use feature 'lexical_subs'; no warnings 'experimental::lexical_subs';
2043 {
2044   {
2045     my sub a { die; }
2046     {
2047       foo();
2048       my sub b;
2049       b ;
2050       main::b();
2051       &main::b;
2052       &main::b();
2053       my $b = \&main::b;
2054       sub b { $b; }
2055     }
2056   }
2057   b();
2058 }
2059 ####
2060 # self-referential lexical subroutine
2061 # CONTEXT use feature 'lexical_subs', 'state'; no warnings 'experimental::lexical_subs';
2062 ();
2063 state sub sb2;
2064 sub sb2 {
2065     sb2 ;
2066 }
2067 ####
2068 # lexical subroutine with outer declaration and inner definition
2069 # CONTEXT use feature 'lexical_subs'; no warnings 'experimental::lexical_subs';
2070 ();
2071 my sub f;
2072 my sub g {
2073     ();
2074     sub f { }
2075 }
2076 ####
2077 # TODO only partially fixed
2078 # lexical state subroutine with outer declaration and inner definition
2079 # CONTEXT use feature 'lexical_subs', 'state'; no warnings 'experimental::lexical_subs';
2080 ();
2081 state sub sb4;
2082 state sub a {
2083     ();
2084     sub sb4 { }
2085 }
2086 state sub sb5;
2087 sub {
2088     ();
2089     sub sb5 { }
2090 } ;
2091 ####
2092 # Elements of %# should not be confused with $#{ array }
2093 () = ${#}{'foo'};
2094 ####
2095 # $; [perl #123357]
2096 $_ = $;;
2097 do {
2098     $;
2099 };
2100 ####
2101 # Ampersand calls and scalar context
2102 # OPTIONS -P
2103 package prototest;
2104 sub foo($$);
2105 foo(bar(),baz());
2106 >>>>
2107 package prototest;
2108 &foo(scalar bar(), scalar baz());
2109 ####
2110 # coderef2text and prototyped sub calls [perl #123435]
2111 is 'foo', 'oo';
2112 ####
2113 # prototypes with unary precedence
2114 package prototest;
2115 sub dollar($) {}
2116 sub optdollar(;$) {}
2117 sub optoptdollar(;;$) {}
2118 sub splat(*) {}
2119 sub optsplat(;*) {}
2120 sub optoptsplat(;;*) {}
2121 sub bar(_) {}
2122 sub optbar(;_) {}
2123 sub optoptbar(;;_) {}
2124 sub plus(+) {}
2125 sub optplus(;+) {}
2126 sub optoptplus(;;+) {}
2127 sub wack(\$) {}
2128 sub optwack(;\$) {}
2129 sub optoptwack(;;\$) {}
2130 sub wackbrack(\[$]) {}
2131 sub optwackbrack(;\[$]) {}
2132 sub optoptwackbrack(;;\[$]) {}
2133 dollar($a < $b);
2134 optdollar($a < $b);
2135 optoptdollar($a < $b);
2136 splat($a < $b);     # Some of these deparse with â€˜&’; if that changes, just
2137 optsplat($a < $b);  # change the tests.
2138 optoptsplat($a < $b);
2139 bar($a < $b);
2140 optbar($a < $b);
2141 optoptbar($a < $b);
2142 plus($a < $b);
2143 optplus($a < $b);
2144 optoptplus($a < $b);
2145 wack($a = $b);
2146 optwack($a = $b);
2147 optoptwack($a = $b);
2148 wackbrack($a = $b);
2149 optwackbrack($a = $b);
2150 optoptwackbrack($a = $b);
2151 >>>>
2152 package prototest;
2153 dollar($a < $b);
2154 optdollar($a < $b);
2155 optoptdollar($a < $b);
2156 &splat($a < $b);
2157 &optsplat($a < $b);
2158 &optoptsplat($a < $b);
2159 bar($a < $b);
2160 optbar($a < $b);
2161 optoptbar($a < $b);
2162 &plus($a < $b);
2163 &optplus($a < $b);
2164 &optoptplus($a < $b);
2165 &wack(\($a = $b));
2166 &optwack(\($a = $b));
2167 &optoptwack(\($a = $b));
2168 &wackbrack(\($a = $b));
2169 &optwackbrack(\($a = $b));
2170 &optoptwackbrack(\($a = $b));
2171 ####
2172 # ensure aelemfast works in the range -128..127 and that there's no
2173 # funky edge cases
2174 my $x;
2175 no strict 'vars';
2176 $x = $a[-256] + $a[-255] + $a[-129] + $a[-128] + $a[-127] + $a[-1] + $a[0];
2177 $x = $a[1] + $a[126] + $a[127] + $a[128] + $a[255] + $a[256];
2178 my @b;
2179 $x = $b[-256] + $b[-255] + $b[-129] + $b[-128] + $b[-127] + $b[-1] + $b[0];
2180 $x = $b[1] + $b[126] + $b[127] + $b[128] + $b[255] + $b[256];
2181 ####
2182 # 'm' must be preserved in m??
2183 m??;
2184 ####
2185 # \(@array) and \(..., (@array), ...)
2186 my(@array, %hash, @a, @b, %c, %d);
2187 () = \(@array);
2188 () = \(%hash);
2189 () = \(@a, (@b), (%c), %d);
2190 () = \(@Foo::array);
2191 () = \(%Foo::hash);
2192 () = \(@Foo::a, (@Foo::b), (%Foo::c), %Foo::d);
2193 ####
2194 # subs synonymous with keywords
2195 main::our();
2196 main::pop();
2197 state();
2198 use feature 'state';
2199 main::state();
2200 ####
2201 # lvalue references
2202 # CONTEXT use feature "state", 'refaliasing', 'lexical_subs'; no warnings 'experimental';
2203 our $x;
2204 \$x = \$x;
2205 my $m;
2206 \$m = \$x;
2207 \my $n = \$x;
2208 (\$x) = @_;
2209 \($x) = @_;
2210 \($m) = @_;
2211 (\$m) = @_;
2212 \my($p) = @_;
2213 (\my $r) = @_;
2214 \($x, my $a) = @{[\$x, \$x]};
2215 (\$x, \my $b) = @{[\$x, \$x]};
2216 \local $x = \3;
2217 \local($x) = \3;
2218 \state $c = \3;
2219 \state($d) = \3;
2220 \our $e = \3;
2221 \our($f) = \3;
2222 \$_[0] = foo();
2223 \($_[1]) = foo();
2224 my @a;
2225 \$a[0] = foo();
2226 \($a[1]) = foo();
2227 \local($a[1]) = foo();
2228 \@a[0,1] = foo();
2229 \(@a[2,3]) = foo();
2230 \local @a[0,1] = (\$a)x2;
2231 \$_{a} = foo();
2232 \($_{b}) = foo();
2233 my %h;
2234 \$h{a} = foo();
2235 \($h{b}) = foo();
2236 \local $h{a} = \$x;
2237 \local($h{b}) = \$x;
2238 \@h{'a','b'} = foo();
2239 \(@h{2,3}) = foo();
2240 \local @h{'a','b'} = (\$x)x2;
2241 \@_ = foo();
2242 \@a = foo();
2243 (\@_) = foo();
2244 (\@a) = foo();
2245 \my @c = foo();
2246 (\my @d) = foo();
2247 \(@_) = foo();
2248 \(@a) = foo();
2249 \my(@g) = foo();
2250 \local @_ = \@_;
2251 (\local @_) = \@_;
2252 \state @e = [1..3];
2253 \state(@f) = \3;
2254 \our @i = [1..3];
2255 \our(@h) = \3;
2256 \%_ = foo();
2257 \%h = foo();
2258 (\%_) = foo();
2259 (\%h) = foo();
2260 \my %c = foo();
2261 (\my %d) = foo();
2262 \local %_ = \%h;
2263 (\local %_) = \%h;
2264 \state %y = {1,2};
2265 \our %z = {1,2};
2266 (\our %zz) = {1,2};
2267 \&a = foo();
2268 (\&a) = foo();
2269 \(&a) = foo();
2270 {
2271   my sub a;
2272   \&a = foo();
2273   (\&a) = foo();
2274   \(&a) = foo();
2275 }
2276 (\$_, $_) = \(1, 2);
2277 $_ == 3 ? \$_ : $_ = \3;
2278 $_ == 3 ? \$_ : \$x = \3;
2279 \($_ == 3 ? $_ : $x) = \3;
2280 for \my $topic (\$1, \$2) {
2281     die;
2282 }
2283 for \state $topic (\$1, \$2) {
2284     die;
2285 }
2286 for \our $topic (\$1, \$2) {
2287     die;
2288 }
2289 for \$_ (\$1, \$2) {
2290     die;
2291 }
2292 for \my @a ([1,2], [3,4]) {
2293     die;
2294 }
2295 for \state @a ([1,2], [3,4]) {
2296     die;
2297 }
2298 for \our @a ([1,2], [3,4]) {
2299     die;
2300 }
2301 for \@_ ([1,2], [3,4]) {
2302     die;
2303 }
2304 for \my %a ({5,6}, {7,8}) {
2305     die;
2306 }
2307 for \our %a ({5,6}, {7,8}) {
2308     die;
2309 }
2310 for \state %a ({5,6}, {7,8}) {
2311     die;
2312 }
2313 for \%_ ({5,6}, {7,8}) {
2314     die;
2315 }
2316 {
2317     my sub a;
2318     for \&a (sub { 9; }, sub { 10; }) {
2319         die;
2320     }
2321 }
2322 for \&a (sub { 9; }, sub { 10; }) {
2323     die;
2324 }
2325 >>>>
2326 our $x;
2327 \$x = \$x;
2328 my $m;
2329 \$m = \$x;
2330 \my $n = \$x;
2331 (\$x) = @_;
2332 (\$x) = @_;
2333 (\$m) = @_;
2334 (\$m) = @_;
2335 (\my $p) = @_;
2336 (\my $r) = @_;
2337 (\$x, \my $a) = @{[\$x, \$x];};
2338 (\$x, \my $b) = @{[\$x, \$x];};
2339 \local $x = \3;
2340 (\local $x) = \3;
2341 \state $c = \3;
2342 (\state $d) = \3;
2343 \our $e = \3;
2344 (\our $f) = \3;
2345 \$_[0] = foo();
2346 (\$_[1]) = foo();
2347 my @a;
2348 \$a[0] = foo();
2349 (\$a[1]) = foo();
2350 (\local $a[1]) = foo();
2351 (\@a[0, 1]) = foo();
2352 (\@a[2, 3]) = foo();
2353 (\local @a[0, 1]) = (\$a) x 2;
2354 \$_{'a'} = foo();
2355 (\$_{'b'}) = foo();
2356 my %h;
2357 \$h{'a'} = foo();
2358 (\$h{'b'}) = foo();
2359 \local $h{'a'} = \$x;
2360 (\local $h{'b'}) = \$x;
2361 (\@h{'a', 'b'}) = foo();
2362 (\@h{2, 3}) = foo();
2363 (\local @h{'a', 'b'}) = (\$x) x 2;
2364 \@_ = foo();
2365 \@a = foo();
2366 (\@_) = foo();
2367 (\@a) = foo();
2368 \my @c = foo();
2369 (\my @d) = foo();
2370 (\(@_)) = foo();
2371 (\(@a)) = foo();
2372 (\(my @g)) = foo();
2373 \local @_ = \@_;
2374 (\local @_) = \@_;
2375 \state @e = [1..3];
2376 (\(state @f)) = \3;
2377 \our @i = [1..3];
2378 (\(our @h)) = \3;
2379 \%_ = foo();
2380 \%h = foo();
2381 (\%_) = foo();
2382 (\%h) = foo();
2383 \my %c = foo();
2384 (\my %d) = foo();
2385 \local %_ = \%h;
2386 (\local %_) = \%h;
2387 \state %y = {1, 2};
2388 \our %z = {1, 2};
2389 (\our %zz) = {1, 2};
2390 \&a = foo();
2391 (\&a) = foo();
2392 (\&a) = foo();
2393 {
2394   my sub a;
2395   \&a = foo();
2396   (\&a) = foo();
2397   (\&a) = foo();
2398 }
2399 (\$_, $_) = \(1, 2);
2400 $_ == 3 ? \$_ : $_ = \3;
2401 $_ == 3 ? \$_ : \$x = \3;
2402 ($_ == 3 ? \$_ : \$x) = \3;
2403 foreach \my $topic (\$1, \$2) {
2404     die;
2405 }
2406 foreach \state $topic (\$1, \$2) {
2407     die;
2408 }
2409 foreach \our $topic (\$1, \$2) {
2410     die;
2411 }
2412 foreach \$_ (\$1, \$2) {
2413     die;
2414 }
2415 foreach \my @a ([1, 2], [3, 4]) {
2416     die;
2417 }
2418 foreach \state @a ([1, 2], [3, 4]) {
2419     die;
2420 }
2421 foreach \our @a ([1, 2], [3, 4]) {
2422     die;
2423 }
2424 foreach \@_ ([1, 2], [3, 4]) {
2425     die;
2426 }
2427 foreach \my %a ({5, 6}, {7, 8}) {
2428     die;
2429 }
2430 foreach \our %a ({5, 6}, {7, 8}) {
2431     die;
2432 }
2433 foreach \state %a ({5, 6}, {7, 8}) {
2434     die;
2435 }
2436 foreach \%_ ({5, 6}, {7, 8}) {
2437     die;
2438 }
2439 {
2440     my sub a;
2441     foreach \&a (sub { 9; } , sub { 10; } ) {
2442         die;
2443     }
2444 }
2445 foreach \&a (sub { 9; } , sub { 10; } ) {
2446     die;
2447 }
2448 ####
2449 # join $foo, pos
2450 my $foo;
2451 $_ = join $foo, pos
2452 >>>>
2453 my $foo;
2454 $_ = join('???', pos $_);
2455 ####
2456 # exists $a[0]
2457 our @a;
2458 exists $a[0];
2459 ####
2460 # my @a; exists $a[0]
2461 my @a;
2462 exists $a[0];
2463 ####
2464 # delete $a[0]
2465 our @a;
2466 delete $a[0];
2467 ####
2468 # my @a; delete $a[0]
2469 my @a;
2470 delete $a[0];
2471 ####
2472 # $_[0][$_[1]]
2473 $_[0][$_[1]];
2474 ####
2475 # f($a[0]);
2476 my @a;
2477 f($a[0]);
2478 ####
2479 #qr/\Q$h{'key'}\E/;
2480 my %h;
2481 qr/\Q$h{'key'}\E/;
2482 ####
2483 # my $x = "$h{foo}";
2484 my %h;
2485 my $x = "$h{'foo'}";
2486 ####
2487 # weird constant hash key
2488 my %h;
2489 my $x = $h{"\000\t\x{100}"};
2490 ####
2491 # multideref and packages
2492 package foo;
2493 my(%bar) = ('a', 'b');
2494 our(@bar) = (1, 2);
2495 $bar{'k'} = $bar[200];
2496 $main::bar{'k'} = $main::bar[200];
2497 $foo::bar{'k'} = $foo::bar[200];
2498 package foo2;
2499 $bar{'k'} = $bar[200];
2500 $main::bar{'k'} = $main::bar[200];
2501 $foo::bar{'k'} = $foo::bar[200];
2502 >>>>
2503 package foo;
2504 my(%bar) = ('a', 'b');
2505 our(@bar) = (1, 2);
2506 $bar{'k'} = $bar[200];
2507 $main::bar{'k'} = $main::bar[200];
2508 $foo::bar{'k'} = $bar[200];
2509 package foo2;
2510 $bar{'k'} = $foo::bar[200];
2511 $main::bar{'k'} = $main::bar[200];
2512 $foo::bar{'k'} = $foo::bar[200];
2513 ####
2514 # multideref and local
2515 my %h;
2516 local $h{'foo'}[0] = 1;
2517 ####
2518 # multideref and exists
2519 my(%h, $i);
2520 my $e = exists $h{'foo'}[$i];
2521 ####
2522 # multideref and delete
2523 my(%h, $i);
2524 my $e = delete $h{'foo'}[$i];
2525 ####
2526 # multideref with leading expression
2527 my $r;
2528 my $x = +($r // [])->{'foo'}[0];
2529 ####
2530 # multideref with complex middle index
2531 my(%h, $i, $j, $k);
2532 my $x = $h{'foo'}[$i + $j]{$k};
2533 ####
2534 # multideref with trailing non-simple index that initially looks simple
2535 # (i.e. the constant "3")
2536 my($r, $i, $j, $k);
2537 my $x = +($r || {})->{'foo'}[$i + $j]{3 + $k};
2538 ####
2539 # chdir
2540 chdir 'file';
2541 chdir FH;
2542 chdir;
2543 ####
2544 # 5.22 bitops
2545 # CONTEXT use feature "bitwise"; no warnings "experimental::bitwise";
2546 $_ = $_ | $_;
2547 $_ = $_ & $_;
2548 $_ = $_ ^ $_;
2549 $_ = ~$_;
2550 $_ = $_ |. $_;
2551 $_ = $_ &. $_;
2552 $_ = $_ ^. $_;
2553 $_ = ~.$_;
2554 $_ |= $_;
2555 $_ &= $_;
2556 $_ ^= $_;
2557 $_ |.= $_;
2558 $_ &.= $_;
2559 $_ ^.= $_;
2560 ####
2561 ####
2562 # Should really use 'no warnings "experimental::signatures"',
2563 # but it doesn't yet deparse correctly.
2564 # anon subs used because this test framework doesn't deparse named subs
2565 # in the DATA code snippets.
2566 #
2567 # general signature
2568 no warnings;
2569 use feature 'signatures';
2570 my $x;
2571 sub ($a, $, $b = $glo::bal, $c = $a, $d = 'foo', $e = -37, $f = 0, $g = 1, $h = undef, $i = $a + 1, $j = /foo/, @) {
2572     $x++;
2573 }
2574 ;
2575 $x++;
2576 ####
2577 # Signature and prototype
2578 no warnings;
2579 use feature 'signatures';
2580 my $x;
2581 sub ($a, $b) : prototype($$) {
2582     $x++;
2583 }
2584 ;
2585 $x++;
2586 ####
2587 # Signature and prototype and attrs
2588 no warnings;
2589 use feature 'signatures';
2590 my $x;
2591 sub ($a, $b) : prototype($$) lvalue {
2592     $x++;
2593 }
2594 ;
2595 $x++;
2596 ####
2597 # Signature and attrs
2598 no warnings;
2599 use feature 'signatures';
2600 my $x;
2601 sub ($a, $b) : lvalue method {
2602     $x++;
2603 }
2604 ;
2605 $x++;
2606 ####
2607 # named array slurp, null body
2608 no warnings;
2609 use feature 'signatures';
2610 sub (@a) {
2611     ;
2612 }
2613 ;
2614 ####
2615 # named hash slurp
2616 no warnings;
2617 use feature 'signatures';
2618 sub ($key, %h) {
2619     $h{$key};
2620 }
2621 ;
2622 ####
2623 # anon hash slurp
2624 no warnings;
2625 use feature 'signatures';
2626 sub ($a, %) {
2627     $a;
2628 }
2629 ;
2630 ####
2631 # parenthesised default arg
2632 no warnings;
2633 use feature 'signatures';
2634 sub ($a, $b = (/foo/), $c = 1) {
2635     $a + $b + $c;
2636 }
2637 ;
2638 ####
2639 # parenthesised default arg with TARGMY
2640 no warnings;
2641 use feature 'signatures';
2642 sub ($a, $b = ($a + 1), $c = 1) {
2643     $a + $b + $c;
2644 }
2645 ;
2646 ####
2647 # empty default
2648 no warnings;
2649 use feature 'signatures';
2650 sub ($a, $=) {
2651     $a;
2652 }
2653 ;
2654 ####
2655 # padrange op within pattern code blocks
2656 /(?{ my($x, $y) = (); })/;
2657 my $a;
2658 /$a(?{ my($x, $y) = (); })/;
2659 my $r1 = qr/(?{ my($x, $y) = (); })/;
2660 my $r2 = qr/$a(?{ my($x, $y) = (); })/;
2661 ####
2662 # don't remove pattern whitespace escapes
2663 /a\ b/;
2664 /a\ b/x;
2665 /a\     b/;
2666 /a\     b/x;
2667 ####
2668 # my attributes
2669 my $s1 :foo(f1, f2) bar(b1, b2);
2670 my @a1 :foo(f1, f2) bar(b1, b2);
2671 my %h1 :foo(f1, f2) bar(b1, b2);
2672 my($s2, @a2, %h2) :foo(f1, f2) bar(b1, b2);
2673 ####
2674 # my class attributes
2675 package Foo::Bar;
2676 my Foo::Bar $s1 :foo(f1, f2) bar(b1, b2);
2677 my Foo::Bar @a1 :foo(f1, f2) bar(b1, b2);
2678 my Foo::Bar %h1 :foo(f1, f2) bar(b1, b2);
2679 my Foo::Bar ($s2, @a2, %h2) :foo(f1, f2) bar(b1, b2);
2680 package main;
2681 my Foo::Bar $s3 :foo(f1, f2) bar(b1, b2);
2682 my Foo::Bar @a3 :foo(f1, f2) bar(b1, b2);
2683 my Foo::Bar %h3 :foo(f1, f2) bar(b1, b2);
2684 my Foo::Bar ($s4, @a4, %h4) :foo(f1, f2) bar(b1, b2);
2685 ####
2686 # avoid false positives in my $x :attribute
2687 'attributes'->import('main', \my $x1, 'foo(bar)'), my $y1;
2688 'attributes'->import('Fooo', \my $x2, 'foo(bar)'), my $y2;
2689 ####
2690 # hash slices and hash key/value slices
2691 my(@a, %h);
2692 our(@oa, %oh);
2693 @a = @h{'foo', 'bar'};
2694 @a = %h{'foo', 'bar'};
2695 @a = delete @h{'foo', 'bar'};
2696 @a = delete %h{'foo', 'bar'};
2697 @oa = @oh{'foo', 'bar'};
2698 @oa = %oh{'foo', 'bar'};
2699 @oa = delete @oh{'foo', 'bar'};
2700 @oa = delete %oh{'foo', 'bar'};
2701 ####
2702 # keys optimised away in void and scalar context
2703 no warnings;
2704 ;
2705 our %h1;
2706 my($x, %h2);
2707 %h1;
2708 keys %h1;
2709 $x = %h1;
2710 $x = keys %h1;
2711 %h2;
2712 keys %h2;
2713 $x = %h2;
2714 $x = keys %h2;
2715 ####
2716 # eq,const optimised away for (index() == -1)
2717 my($a, $b);
2718 our $c;
2719 $c = index($a, $b) == 2;
2720 $c = rindex($a, $b) == 2;
2721 $c = index($a, $b) == -1;
2722 $c = rindex($a, $b) == -1;
2723 $c = index($a, $b) != -1;
2724 $c = rindex($a, $b) != -1;
2725 $c = (index($a, $b) == -1);
2726 $c = (rindex($a, $b) == -1);
2727 $c = (index($a, $b) != -1);
2728 $c = (rindex($a, $b) != -1);
2729 ####
2730 # eq,const,sassign,madmy optimised away for (index() == -1)
2731 my($a, $b);
2732 my $c;
2733 $c = index($a, $b) == 2;
2734 $c = rindex($a, $b) == 2;
2735 $c = index($a, $b) == -1;
2736 $c = rindex($a, $b) == -1;
2737 $c = index($a, $b) != -1;
2738 $c = rindex($a, $b) != -1;
2739 $c = (index($a, $b) == -1);
2740 $c = (rindex($a, $b) == -1);
2741 $c = (index($a, $b) != -1);
2742 $c = (rindex($a, $b) != -1);
2743 ####
2744 # plain multiconcat
2745 my($a, $b, $c, $d, @a);
2746 $d = length $a . $b . $c;
2747 $d = length($a) . $b . $c;
2748 print '' . $a;
2749 push @a, ($a . '') * $b;
2750 unshift @a, "$a" * ($b . '');
2751 print $a . 'x' . $b . $c;
2752 print $a . 'x' . $b . $c, $d;
2753 print $b . $c . ($a . $b);
2754 print $b . $c . ($a . $b);
2755 print $b . $c . @a;
2756 print $a . "\x{100}";
2757 ####
2758 # double-quoted multiconcat
2759 my($a, $b, $c, $d, @a);
2760 print "${a}x\x{100}$b$c";
2761 print "$a\Q$b\E$c\Ua$a\E\Lb$b\uc$c\E$a${b}c$c";
2762 print "A=$a[length 'b' . $c . 'd'] b=$b";
2763 print "A=@a B=$b";
2764 print "\x{101}$a\x{100}";
2765 $a = qr/\Q
2766 $b $c
2767 \x80
2768 \x{100}
2769 \E$c
2770 /;
2771 ####
2772 # sprintf multiconcat
2773 my($a, $b, $c, $d, @a);
2774 print sprintf("%s%s%%%sx%s\x{100}%s", $a, $b, $c, scalar @a, $d);
2775 ####
2776 # multiconcat with lexical assign
2777 my($a, $b, $c, $d, $e, @a);
2778 $d = 'foo' . $a;
2779 $d = "foo$a";
2780 $d = $a . '';
2781 $d = 'foo' . $a . 'bar';
2782 $d = $a . $b;
2783 $d = $a . $b . $c;
2784 $d = $a . $b . $c . @a;
2785 $e = ($d = $a . $b . $c);
2786 $d = !$a . $b . $c;
2787 $a = $b . $c . ($a . $b);
2788 $e = f($d = !$a . $b) . $c;
2789 $d = "${a}x\x{100}$b$c";
2790 f($d = !$a . $b . $c);
2791 ####
2792 # multiconcat with lexical my
2793 my($a, $b, $c, $d, $e, @a);
2794 my $d1 = 'foo' . $a;
2795 my $d2 = "foo$a";
2796 my $d3 = $a . '';
2797 my $d4 = 'foo' . $a . 'bar';
2798 my $d5 = $a . $b;
2799 my $d6 = $a . $b . $c;
2800 my $e7 = ($d = $a . $b . $c);
2801 my $d8 = !$a . $b . $c;
2802 my $d9 = $b . $c . ($a . $b);
2803 my $da = f($d = !$a . $b) . $c;
2804 my $dc = "${a}x\x{100}$b$c";
2805 f(my $db = !$a . $b . $c);
2806 my $dd = $a . $b . $c . @a;
2807 ####
2808 # multiconcat with lexical append
2809 my($a, $b, $c, $d, $e, @a);
2810 $d .= '';
2811 $d .= $a;
2812 $d .= "$a";
2813 $d .= 'foo' . $a;
2814 $d .= "foo$a";
2815 $d .= $a . '';
2816 $d .= 'foo' . $a . 'bar';
2817 $d .= $a . $b;
2818 $d .= $a . $b . $c;
2819 $d .= $a . $b . @a;
2820 $e .= ($d = $a . $b . $c);
2821 $d .= !$a . $b . $c;
2822 $a .= $b . $c . ($a . $b);
2823 $e .= f($d .= !$a . $b) . $c;
2824 f($d .= !$a . $b . $c);
2825 $d .= "${a}x\x{100}$b$c";
2826 ####
2827 # multiconcat with expression assign
2828 my($a, $b, $c, @a);
2829 our($d, $e);
2830 $d = 'foo' . $a;
2831 $d = "foo$a";
2832 $d = $a . '';
2833 $d = 'foo' . $a . 'bar';
2834 $d = $a . $b;
2835 $d = $a . $b . $c;
2836 $d = $a . $b . @a;
2837 $e = ($d = $a . $b . $c);
2838 $a["-$b-"] = !$a . $b . $c;
2839 $a[$b]{$c}{$d ? $a : $b . $c} = !$a . $b . $c;
2840 $a = $b . $c . ($a . $b);
2841 $e = f($d = !$a . $b) . $c;
2842 $d = "${a}x\x{100}$b$c";
2843 f($d = !$a . $b . $c);
2844 ####
2845 # multiconcat with expression concat
2846 my($a, $b, $c, @a);
2847 our($d, $e);
2848 $d .= 'foo' . $a;
2849 $d .= "foo$a";
2850 $d .= $a . '';
2851 $d .= 'foo' . $a . 'bar';
2852 $d .= $a . $b;
2853 $d .= $a . $b . $c;
2854 $d .= $a . $b . @a;
2855 $e .= ($d .= $a . $b . $c);
2856 $a["-$b-"] .= !$a . $b . $c;
2857 $a[$b]{$c}{$d ? $a : $b . $c} .= !$a . $b . $c;
2858 $a .= $b . $c . ($a . $b);
2859 $e .= f($d .= !$a . $b) . $c;
2860 $d .= "${a}x\x{100}$b$c";
2861 f($d .= !$a . $b . $c);
2862 ####
2863 # multiconcat with CORE::sprintf
2864 # CONTEXT sub sprintf {}
2865 my($a, $b);
2866 my $x = CORE::sprintf('%s%s', $a, $b);
2867 ####
2868 # multiconcat with backticks
2869 my($a, $b);
2870 our $x;
2871 $x = `$a-$b`;
2872 ####
2873 # multiconcat within qr//
2874 my($r, $a, $b);
2875 $r = qr/abc\Q$a-$b\Exyz/;
2876 ####
2877 # tr with unprintable characters
2878 my $str;
2879 $str = 'foo';
2880 $str =~ tr/\cA//;
2881 ####
2882 # CORE::foo special case in bareword parsing
2883 print $CORE::foo, $CORE::foo::bar;
2884 print @CORE::foo, @CORE::foo::bar;
2885 print %CORE::foo, %CORE::foo::bar;
2886 print $CORE::foo{'a'}, $CORE::foo::bar{'a'};
2887 print &CORE::foo, &CORE::foo::bar;
2888 print &CORE::foo(), &CORE::foo::bar();
2889 print \&CORE::foo, \&CORE::foo::bar;
2890 print *CORE::foo, *CORE::foo::bar;
2891 print stat CORE::foo::, stat CORE::foo::bar;
2892 print CORE::foo:: 1;
2893 print CORE::foo::bar 2;
2894 ####
2895 # trailing colons on glob names
2896 no strict 'vars';
2897 $Foo::::baz = 1;
2898 print $foo, $foo::, $foo::::;
2899 print @foo, @foo::, @foo::::;
2900 print %foo, %foo::, %foo::::;
2901 print $foo{'a'}, $foo::{'a'}, $foo::::{'a'};
2902 print &foo, &foo::, &foo::::;
2903 print &foo(), &foo::(), &foo::::();
2904 print \&foo, \&foo::, \&foo::::;
2905 print *foo, *foo::, *foo::::;
2906 print stat Foo, stat Foo::::;
2907 print Foo 1;
2908 print Foo:::: 2;
2909 ####
2910 # trailing colons mixed with CORE
2911 no strict 'vars';
2912 print $CORE, $CORE::, $CORE::::;
2913 print @CORE, @CORE::, @CORE::::;
2914 print %CORE, %CORE::, %CORE::::;
2915 print $CORE{'a'}, $CORE::{'a'}, $CORE::::{'a'};
2916 print &CORE, &CORE::, &CORE::::;
2917 print &CORE(), &CORE::(), &CORE::::();
2918 print \&CORE, \&CORE::, \&CORE::::;
2919 print *CORE, *CORE::, *CORE::::;
2920 print stat CORE, stat CORE::::;
2921 print CORE 1;
2922 print CORE:::: 2;
2923 print $CORE::foo, $CORE::foo::, $CORE::foo::::;
2924 print @CORE::foo, @CORE::foo::, @CORE::foo::::;
2925 print %CORE::foo, %CORE::foo::, %CORE::foo::::;
2926 print $CORE::foo{'a'}, $CORE::foo::{'a'}, $CORE::foo::::{'a'};
2927 print &CORE::foo, &CORE::foo::, &CORE::foo::::;
2928 print &CORE::foo(), &CORE::foo::(), &CORE::foo::::();
2929 print \&CORE::foo, \&CORE::foo::, \&CORE::foo::::;
2930 print *CORE::foo, *CORE::foo::, *CORE::foo::::;
2931 print stat CORE::foo::, stat CORE::foo::::;
2932 print CORE::foo:: 1;
2933 print CORE::foo:::: 2;
2934 ####
2935 # \&foo
2936 my sub foo {
2937     1;
2938 }
2939 no strict 'vars';
2940 print \&main::foo;
2941 print \&{foo};
2942 print \&bar;
2943 use strict 'vars';
2944 print \&main::foo;
2945 print \&{foo};
2946 print \&main::bar;
2947 ####
2948 # exists(&foo)
2949 my sub foo {
2950     1;
2951 }
2952 no strict 'vars';
2953 print exists &main::foo;
2954 print exists &{foo};
2955 print exists &bar;
2956 use strict 'vars';
2957 print exists &main::foo;
2958 print exists &{foo};
2959 print exists &main::bar;
2960 # precedence of optimised-away 'keys' (OPpPADHV_ISKEYS/OPpRV2HV_ISKEYS)
2961 my($r1, %h1, $res);
2962 our($r2, %h2);
2963 $res = keys %h1;
2964 $res = keys %h2;
2965 $res = keys %$r1;
2966 $res = keys %$r2;
2967 $res = keys(%h1) / 2 - 1;
2968 $res = keys(%h2) / 2 - 1;
2969 $res = keys(%$r1) / 2 - 1;
2970 $res = keys(%$r2) / 2 - 1;
2971 ####
2972 # ditto in presence of sub keys {}
2973 # CONTEXT sub keys {}
2974 no warnings;
2975 my($r1, %h1, $res);
2976 our($r2, %h2);
2977 CORE::keys %h1;
2978 CORE::keys(%h1) / 2;
2979 $res = CORE::keys %h1;
2980 $res = CORE::keys %h2;
2981 $res = CORE::keys %$r1;
2982 $res = CORE::keys %$r2;
2983 $res = CORE::keys(%h1) / 2 - 1;
2984 $res = CORE::keys(%h2) / 2 - 1;
2985 $res = CORE::keys(%$r1) / 2 - 1;
2986 $res = CORE::keys(%$r2) / 2 - 1;
2987 ####
2988 # concat: STACKED: ambiguity between .= and optimised nested
2989 my($a, $b);
2990 $b = $a . $a . $a;
2991 (($a .= $a) .= $a) .= $a;
2992 ####
2993 # multiconcat: $$ within string
2994 my($a, $x);
2995 $x = "${$}abc";
2996 $x = "\$$a";
2997 ####
2998 # single state aggregate assignment
2999 # CONTEXT use feature "state";
3000 state @a = (1, 2, 3);
3001 state %h = ('a', 1, 'b', 2);
3002 ####
3003 # state var with attribute
3004 # CONTEXT use feature "state";
3005 state $x :shared;
3006 state $y :shared = 1;
3007 state @a :shared;
3008 state @b :shared = (1, 2);
3009 state %h :shared;
3010 state %i :shared = ('a', 1, 'b', 2);