This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
c6a3bb887f9bf360f1aac68a31f89746f3c73ee0
[perl5.git] / t / lib / warnings / op
1   op.c          AOK
2
3      Found = in conditional, should be ==
4         1 if $a = 1 ;
5
6      Useless use of time in void context
7      Useless use of a variable in void context
8      Useless use of a constant in void context
9         time ;
10         $a ;
11         "abc"
12
13      Useless use of sort in scalar context
14         my $x = sort (2,1,3);
15
16      Applying %s to %s will act on scalar(%s)
17         my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
18         @a =~ /abc/ ;
19         @a =~ s/a/b/ ;
20         @a =~ tr/a/b/ ;
21         @$b =~ /abc/ ;
22         @$b =~ s/a/b/ ;
23         @$b =~ tr/a/b/ ;
24         %a =~ /abc/ ;
25         %a =~ s/a/b/ ;
26         %a =~ tr/a/b/ ;
27         %$c =~ /abc/ ;
28         %$c =~ s/a/b/ ;
29         %$c =~ tr/a/b/ ;
30
31
32      Parentheses missing around "my" list at -e line 1.
33        my $a, $b = (1,2);
34  
35      Parentheses missing around "local" list at -e line 1.
36        local $a, $b = (1,2);
37  
38      Bareword found in conditional at -e line 1.
39        use warnings 'bareword'; my $x = print(ABC || 1);
40  
41      Value of %s may be \"0\"; use \"defined\" 
42         $x = 1 if $x = <FH> ;
43         $x = 1 while $x = <FH> ;
44
45      Subroutine fred redefined at -e line 1.
46        sub fred{1;} sub fred{1;}
47  
48      Constant subroutine %s redefined 
49         sub fred() {1;} sub fred() {1;}
50  
51      Format FRED redefined at /tmp/x line 5.
52        format FRED =
53        .
54        format FRED =
55        .
56  
57      Array @%s missing the @ in argument %d of %s() 
58         push fred ;
59  
60      Hash %%%s missing the %% in argument %d of %s() 
61         keys joe ;
62  
63      Statement unlikely to be reached
64         (Maybe you meant system() when you said exec()?
65         exec "true" ; my $a
66
67      defined(@array) is deprecated
68         (Maybe you should just omit the defined()?)
69         my @a ; defined @a ;
70         defined (@a = (1,2,3)) ;
71
72      defined(%hash) is deprecated
73         (Maybe you should just omit the defined()?)
74         my %h ; defined %h ;
75
76      "my %s" used in sort comparison
77
78      $[ used in comparison (did you mean $] ?)
79
80      length() used on @array (did you mean "scalar(@array)"?)
81      length() used on %hash (did you mean "scalar(keys %hash)"?)
82
83      /---/ should probably be written as "---"
84         join(/---/, @foo);
85
86     %s() called too early to check prototype            [Perl_peep]
87         fred() ; sub fred ($$) {}
88
89
90     Package '%s' not found (did you use the incorrect case?)
91
92     Use of /g modifier is meaningless in split
93
94     Possible precedence problem on bitwise %c operator  [Perl_ck_bitop]
95
96     Mandatory Warnings 
97     ------------------
98     Prototype mismatch:         [cv_ckproto]
99         sub fred() ;
100         sub fred($) {}
101
102     oops: oopsAV                [oopsAV]        TODO
103     oops: oopsHV                [oopsHV]        TODO
104     
105 __END__
106 # op.c
107 use warnings 'syntax' ;
108 1 if $a = 1 ;
109 no warnings 'syntax' ;
110 1 if $a = 1 ;
111 EXPECT
112 Found = in conditional, should be == at - line 3.
113 ########
114 # op.c
115 use warnings 'syntax' ;
116 use constant foo => 1;
117 1 if $a = foo ;
118 no warnings 'syntax' ;
119 1 if $a = foo ;
120 EXPECT
121 ########
122 # op.c
123 my (@foo, %foo);
124 %main::foo->{"bar"};
125 %foo->{"bar"};
126 @main::foo->[23];
127 @foo->[23];
128 $main::foo = {}; %$main::foo->{"bar"};
129 $foo = {}; %$foo->{"bar"};
130 $main::foo = []; @$main::foo->[34];
131 $foo = []; @$foo->[34];
132 no warnings 'deprecated';
133 %main::foo->{"bar"};
134 %foo->{"bar"};
135 @main::foo->[23];
136 @foo->[23];
137 $main::foo = {}; %$main::foo->{"bar"};
138 $foo = {}; %$foo->{"bar"};
139 $main::foo = []; @$main::foo->[34];
140 $foo = []; @$foo->[34];
141 EXPECT
142 Using a hash as a reference is deprecated at - line 3.
143 Using a hash as a reference is deprecated at - line 4.
144 Using an array as a reference is deprecated at - line 5.
145 Using an array as a reference is deprecated at - line 6.
146 Using a hash as a reference is deprecated at - line 7.
147 Using a hash as a reference is deprecated at - line 8.
148 Using an array as a reference is deprecated at - line 9.
149 Using an array as a reference is deprecated at - line 10.
150 ########
151 # op.c
152 use warnings 'void' ; close STDIN ;
153 #line 2
154 1 x 3 ;                 # OP_REPEAT (folded)
155 (1) x 3 ;               # OP_REPEAT
156                         # OP_GVSV
157 wantarray ;             # OP_WANTARRAY
158                         # OP_GV
159                         # OP_PADSV
160                         # OP_PADAV
161                         # OP_PADHV
162                         # OP_PADANY
163                         # OP_AV2ARYLEN
164 ref ;                   # OP_REF
165 \@a ;                   # OP_REFGEN
166 \$a ;                   # OP_SREFGEN
167 defined $a ;            # OP_DEFINED
168 hex $a ;                # OP_HEX
169 oct $a ;                # OP_OCT
170 length $a ;             # OP_LENGTH
171 substr $a,1 ;           # OP_SUBSTR
172 vec $a,1,2 ;            # OP_VEC
173 index $a,1,2 ;          # OP_INDEX
174 rindex $a,1,2 ;         # OP_RINDEX
175 sprintf $a ;            # OP_SPRINTF
176 $a[0] ;                 # OP_AELEM
177                         # OP_AELEMFAST
178 @a[0] ;                 # OP_ASLICE
179 #values %a ;            # OP_VALUES
180 #keys %a ;              # OP_KEYS
181 $a{0} ;                 # OP_HELEM
182 @a{0} ;                 # OP_HSLICE
183 unpack "a", "a" ;       # OP_UNPACK
184 pack $a,"" ;            # OP_PACK
185 join "" ;               # OP_JOIN
186 (@a)[0,1] ;             # OP_LSLICE
187                         # OP_ANONLIST
188                         # OP_ANONHASH
189 sort(1,2) ;             # OP_SORT
190 reverse(1,2) ;          # OP_REVERSE
191                         # OP_RANGE
192                         # OP_FLIP
193 (1 ..2) ;               # OP_FLOP
194 caller ;                # OP_CALLER
195 fileno STDIN ;          # OP_FILENO
196 eof STDIN ;             # OP_EOF
197 tell STDIN ;            # OP_TELL
198 readlink 1;             # OP_READLINK
199 time ;                  # OP_TIME
200 localtime ;             # OP_LOCALTIME
201 gmtime ;                # OP_GMTIME
202 eval { getgrnam 1 };    # OP_GGRNAM
203 eval { getgrgid 1 };    # OP_GGRGID
204 eval { getpwnam 1 };    # OP_GPWNAM
205 eval { getpwuid 1 };    # OP_GPWUID
206 prototype "foo";        # OP_PROTOTYPE
207 $a ~~ $b;               # OP_SMARTMATCH
208 $a <=> $b;              # OP_NCMP
209 use 5.015;
210 __SUB__                 # OP_RUNCV
211 EXPECT
212 Useless use of a constant ("111") in void context at - line 2.
213 Useless use of repeat (x) in void context at - line 3.
214 Useless use of wantarray in void context at - line 5.
215 Useless use of reference-type operator in void context at - line 12.
216 Useless use of reference constructor in void context at - line 13.
217 Useless use of single ref constructor in void context at - line 14.
218 Useless use of defined operator in void context at - line 15.
219 Useless use of hex in void context at - line 16.
220 Useless use of oct in void context at - line 17.
221 Useless use of length in void context at - line 18.
222 Useless use of substr in void context at - line 19.
223 Useless use of vec in void context at - line 20.
224 Useless use of index in void context at - line 21.
225 Useless use of rindex in void context at - line 22.
226 Useless use of sprintf in void context at - line 23.
227 Useless use of array element in void context at - line 24.
228 Useless use of array slice in void context at - line 26.
229 Useless use of hash element in void context at - line 29.
230 Useless use of hash slice in void context at - line 30.
231 Useless use of unpack in void context at - line 31.
232 Useless use of pack in void context at - line 32.
233 Useless use of join or string in void context at - line 33.
234 Useless use of list slice in void context at - line 34.
235 Useless use of sort in void context at - line 37.
236 Useless use of reverse in void context at - line 38.
237 Useless use of range (or flop) in void context at - line 41.
238 Useless use of caller in void context at - line 42.
239 Useless use of fileno in void context at - line 43.
240 Useless use of eof in void context at - line 44.
241 Useless use of tell in void context at - line 45.
242 Useless use of readlink in void context at - line 46.
243 Useless use of time in void context at - line 47.
244 Useless use of localtime in void context at - line 48.
245 Useless use of gmtime in void context at - line 49.
246 Useless use of getgrnam in void context at - line 50.
247 Useless use of getgrgid in void context at - line 51.
248 Useless use of getpwnam in void context at - line 52.
249 Useless use of getpwuid in void context at - line 53.
250 Useless use of subroutine prototype in void context at - line 54.
251 Useless use of smart match in void context at - line 55.
252 Useless use of numeric comparison (<=>) in void context at - line 56.
253 Useless use of __SUB__ in void context at - line 58.
254 ########
255 # op.c
256 use warnings 'void' ; close STDIN ;
257 my $x = sort (2,1,3);
258 no warnings 'void' ;
259 $x = sort (2,1,3);
260 EXPECT
261 Useless use of sort in scalar context at - line 3.
262 ########
263 # op.c
264 no warnings 'void' ; close STDIN ;
265 1 x 3 ;                 # OP_REPEAT
266                         # OP_GVSV
267 wantarray ;             # OP_WANTARRAY
268                         # OP_GV
269                         # OP_PADSV
270                         # OP_PADAV
271                         # OP_PADHV
272                         # OP_PADANY
273                         # OP_AV2ARYLEN
274 ref ;                   # OP_REF
275 \@a ;                   # OP_REFGEN
276 \$a ;                   # OP_SREFGEN
277 defined $a ;            # OP_DEFINED
278 hex $a ;                # OP_HEX
279 oct $a ;                # OP_OCT
280 length $a ;             # OP_LENGTH
281 substr $a,1 ;           # OP_SUBSTR
282 vec $a,1,2 ;            # OP_VEC
283 index $a,1,2 ;          # OP_INDEX
284 rindex $a,1,2 ;         # OP_RINDEX
285 sprintf $a ;            # OP_SPRINTF
286 $a[0] ;                 # OP_AELEM
287                         # OP_AELEMFAST
288 @a[0] ;                 # OP_ASLICE
289 #values %a ;            # OP_VALUES
290 #keys %a ;              # OP_KEYS
291 $a{0} ;                 # OP_HELEM
292 @a{0} ;                 # OP_HSLICE
293 unpack "a", "a" ;       # OP_UNPACK
294 pack $a,"" ;            # OP_PACK
295 join "" ;               # OP_JOIN
296 (@a)[0,1] ;             # OP_LSLICE
297                         # OP_ANONLIST
298                         # OP_ANONHASH
299 sort(1,2) ;             # OP_SORT
300 reverse(1,2) ;          # OP_REVERSE
301                         # OP_RANGE
302                         # OP_FLIP
303 (1 ..2) ;               # OP_FLOP
304 caller ;                # OP_CALLER
305 fileno STDIN ;          # OP_FILENO
306 eof STDIN ;             # OP_EOF
307 tell STDIN ;            # OP_TELL
308 readlink 1;             # OP_READLINK
309 time ;                  # OP_TIME
310 localtime ;             # OP_LOCALTIME
311 gmtime ;                # OP_GMTIME
312 eval { getgrnam 1 };    # OP_GGRNAM
313 eval { getgrgid 1 };    # OP_GGRGID
314 eval { getpwnam 1 };    # OP_GPWNAM
315 eval { getpwuid 1 };    # OP_GPWUID
316 prototype "foo";        # OP_PROTOTYPE
317 EXPECT
318 ########
319 # op.c
320 use warnings 'void' ;
321 for (@{[0]}) { "$_" }           # check warning isn't duplicated
322 no warnings 'void' ;
323 for (@{[0]}) { "$_" }           # check warning isn't duplicated
324 EXPECT
325 Useless use of string in void context at - line 3.
326 ########
327 # op.c
328 use warnings 'void' ;
329 use Config ;
330 BEGIN {
331     if ( ! $Config{d_telldir}) {
332         print <<EOM ;
333 SKIPPED
334 # telldir not present
335 EOM
336         exit 
337     }
338 }
339 telldir 1 ;             # OP_TELLDIR
340 no warnings 'void' ;
341 telldir 1 ;             # OP_TELLDIR
342 EXPECT
343 Useless use of telldir in void context at - line 13.
344 ########
345 # op.c
346 use warnings 'void' ;
347 use Config ;
348 BEGIN {
349     if ( ! $Config{d_getppid}) {
350         print <<EOM ;
351 SKIPPED
352 # getppid not present
353 EOM
354         exit 
355     }
356 }
357 getppid ;               # OP_GETPPID
358 no warnings 'void' ;
359 getppid ;               # OP_GETPPID
360 EXPECT
361 Useless use of getppid in void context at - line 13.
362 ########
363 # op.c
364 use warnings 'void' ;
365 use Config ;
366 BEGIN {
367     if ( ! $Config{d_getpgrp}) {
368         print <<EOM ;
369 SKIPPED
370 # getpgrp not present
371 EOM
372         exit 
373     }
374 }
375 getpgrp ;               # OP_GETPGRP
376 no warnings 'void' ;
377 getpgrp ;               # OP_GETPGRP
378 EXPECT
379 Useless use of getpgrp in void context at - line 13.
380 ########
381 # op.c
382 use warnings 'void' ;
383 use Config ;
384 BEGIN {
385     if ( ! $Config{d_times}) {
386         print <<EOM ;
387 SKIPPED
388 # times not present
389 EOM
390         exit 
391     }
392 }
393 times ;                 # OP_TMS
394 no warnings 'void' ;
395 times ;                 # OP_TMS
396 EXPECT
397 Useless use of times in void context at - line 13.
398 ########
399 # op.c
400 use warnings 'void' ;
401 use Config ;
402 BEGIN {
403     if ( ! $Config{d_getprior} or $^O eq 'os2') { # Locks before fixpak22
404         print <<EOM ;
405 SKIPPED
406 # getpriority not present
407 EOM
408         exit 
409     }
410 }
411 getpriority 1,2;        # OP_GETPRIORITY
412 no warnings 'void' ;
413 getpriority 1,2;        # OP_GETPRIORITY
414 EXPECT
415 Useless use of getpriority in void context at - line 13.
416 ########
417 # op.c
418 use warnings 'void' ;
419 use Config ;
420 BEGIN {
421     if ( ! $Config{d_getlogin}) {
422         print <<EOM ;
423 SKIPPED
424 # getlogin not present
425 EOM
426         exit 
427     }
428 }
429 getlogin ;                      # OP_GETLOGIN
430 no warnings 'void' ;
431 getlogin ;                      # OP_GETLOGIN
432 EXPECT
433 Useless use of getlogin in void context at - line 13.
434 ########
435 # op.c
436 use warnings 'void' ;
437 use Config ; BEGIN {
438 if ( ! $Config{d_socket}) {
439     print <<EOM ;
440 SKIPPED
441 # getsockname not present
442 # getpeername not present
443 # gethostbyname not present
444 # gethostbyaddr not present
445 # gethostent not present
446 # getnetbyname not present
447 # getnetbyaddr not present
448 # getnetent not present
449 # getprotobyname not present
450 # getprotobynumber not present
451 # getprotoent not present
452 # getservbyname not present
453 # getservbyport not present
454 # getservent not present
455 EOM
456     exit 
457 } }
458 getsockname STDIN ;     # OP_GETSOCKNAME
459 getpeername STDIN ;     # OP_GETPEERNAME
460 gethostbyname 1 ;       # OP_GHBYNAME
461 gethostbyaddr 1,2;      # OP_GHBYADDR
462 gethostent ;            # OP_GHOSTENT
463 getnetbyname 1 ;        # OP_GNBYNAME
464 getnetbyaddr 1,2 ;      # OP_GNBYADDR
465 getnetent ;             # OP_GNETENT
466 getprotobyname 1;       # OP_GPBYNAME
467 getprotobynumber 1;     # OP_GPBYNUMBER
468 getprotoent ;           # OP_GPROTOENT
469 getservbyname 1,2;      # OP_GSBYNAME
470 getservbyport 1,2;      # OP_GSBYPORT
471 getservent ;            # OP_GSERVENT
472
473 no warnings 'void' ;
474 getsockname STDIN ;     # OP_GETSOCKNAME
475 getpeername STDIN ;     # OP_GETPEERNAME
476 gethostbyname 1 ;       # OP_GHBYNAME
477 gethostbyaddr 1,2;      # OP_GHBYADDR
478 gethostent ;            # OP_GHOSTENT
479 getnetbyname 1 ;        # OP_GNBYNAME
480 getnetbyaddr 1,2 ;      # OP_GNBYADDR
481 getnetent ;             # OP_GNETENT
482 getprotobyname 1;       # OP_GPBYNAME
483 getprotobynumber 1;     # OP_GPBYNUMBER
484 getprotoent ;           # OP_GPROTOENT
485 getservbyname 1,2;      # OP_GSBYNAME
486 getservbyport 1,2;      # OP_GSBYPORT
487 getservent ;            # OP_GSERVENT
488 INIT {
489    # some functions may not be there, so we exit without running
490    exit;
491 }
492 EXPECT
493 Useless use of getsockname in void context at - line 24.
494 Useless use of getpeername in void context at - line 25.
495 Useless use of gethostbyname in void context at - line 26.
496 Useless use of gethostbyaddr in void context at - line 27.
497 Useless use of gethostent in void context at - line 28.
498 Useless use of getnetbyname in void context at - line 29.
499 Useless use of getnetbyaddr in void context at - line 30.
500 Useless use of getnetent in void context at - line 31.
501 Useless use of getprotobyname in void context at - line 32.
502 Useless use of getprotobynumber in void context at - line 33.
503 Useless use of getprotoent in void context at - line 34.
504 Useless use of getservbyname in void context at - line 35.
505 Useless use of getservbyport in void context at - line 36.
506 Useless use of getservent in void context at - line 37.
507 ########
508 # op.c
509 use warnings 'void' ;
510 *a ; # OP_RV2GV
511 $a ; # OP_RV2SV
512 @a ; # OP_RV2AV
513 %a ; # OP_RV2HV
514 no warnings 'void' ;
515 *a ; # OP_RV2GV
516 $a ; # OP_RV2SV
517 @a ; # OP_RV2AV
518 %a ; # OP_RV2HV
519 EXPECT
520 Useless use of a variable in void context at - line 3.
521 Useless use of a variable in void context at - line 4.
522 Useless use of a variable in void context at - line 5.
523 Useless use of a variable in void context at - line 6.
524 ########
525 # op.c
526 use warnings 'void' ;
527 "abc"; # OP_CONST
528 7 ; # OP_CONST
529 "x" . "y"; # optimized to OP_CONST
530 2 + 2; # optimized to OP_CONST
531 use constant U => undef;
532 U;
533 qq/"    \n/;
534 5 || print "bad\n";     # test OPpCONST_SHORTCIRCUIT
535 print "boo\n" if U;     # test OPpCONST_SHORTCIRCUIT
536 no warnings 'void' ;
537 "abc"; # OP_CONST
538 7 ; # OP_CONST
539 "x" . "y"; # optimized to OP_CONST
540 2 + 2; # optimized to OP_CONST
541 EXPECT
542 Useless use of a constant ("abc") in void context at - line 3.
543 Useless use of a constant (7) in void context at - line 4.
544 Useless use of a constant ("xy") in void context at - line 5.
545 Useless use of a constant (4) in void context at - line 6.
546 Useless use of a constant (undef) in void context at - line 8.
547 Useless use of a constant ("\"\t\n") in void context at - line 9.
548 ########
549 # op.c
550 use utf8;
551 use open qw( :utf8 :std );
552 use warnings 'void' ;
553 "àḆc"; # OP_CONST
554 "Ẋ" . "ƴ"; # optimized to OP_CONST
555 FOO;     # Bareword optimized to OP_CONST
556 use constant ů => undef;
557 ů;
558 5 || print "bad\n";     # test OPpCONST_SHORTCIRCUIT
559 print "boo\n" if ů;    # test OPpCONST_SHORTCIRCUIT
560 no warnings 'void' ;
561 "àḆc"; # OP_CONST
562 "Ẋ" . "ƴ"; # optimized to OP_CONST
563 EXPECT
564 Useless use of a constant ("\340\x{1e06}c") in void context at - line 5.
565 Useless use of a constant ("\x{1e8a}\x{1b4}") in void context at - line 6.
566 Useless use of a constant ("\x{ff26}\x{ff2f}\x{ff2f}") in void context at - line 7.
567 Useless use of a constant (undef) in void context at - line 9.
568 ########
569 # op.c
570 #
571 use warnings 'misc' ;
572 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;my $d = 'test';
573 @a =~ /abc/ ;
574 @a2 =~ s/a/b/ ;
575 @a3 =~ tr/a/b/ ;
576 @$b =~ /abc/ ;
577 @$b =~ s/a/b/ ;
578 @$b =~ tr/a/b/ ;
579 %a =~ /abc/ ;
580 %a2 =~ s/a/b/ ;
581 %a3 =~ tr/a/b/ ;
582 %$c =~ /abc/ ;
583 %$c =~ s/a/b/ ;
584 %$c =~ tr/a/b/ ;
585 $d =~ tr/a/b/d ;
586 $d2 =~ tr/a/bc/;
587 {
588 no warnings 'misc' ;
589 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ; my $d = 'test';
590 @a =~ /abc/ ;
591 @a =~ s/a/b/ ;
592 @a =~ tr/a/b/ ;
593 @$b =~ /abc/ ;
594 @$b =~ s/a/b/ ;
595 @$b =~ tr/a/b/ ;
596 %a =~ /abc/ ;
597 %a =~ s/a/b/ ;
598 %a =~ tr/a/b/ ;
599 %$c =~ /abc/ ;
600 %$c =~ s/a/b/ ;
601 %$c =~ tr/a/b/ ;
602 $d =~ tr/a/b/d ;
603 $d =~ tr/a/bc/ ;
604 }
605 EXPECT
606 Applying pattern match (m//) to @a will act on scalar(@a) at - line 5.
607 Applying substitution (s///) to @a2 will act on scalar(@a2) at - line 6.
608 Applying transliteration (tr///) to @a3 will act on scalar(@a3) at - line 7.
609 Applying pattern match (m//) to @array will act on scalar(@array) at - line 8.
610 Applying substitution (s///) to @array will act on scalar(@array) at - line 9.
611 Applying transliteration (tr///) to @array will act on scalar(@array) at - line 10.
612 Applying pattern match (m//) to %a will act on scalar(%a) at - line 11.
613 Applying substitution (s///) to %a2 will act on scalar(%a2) at - line 12.
614 Applying transliteration (tr///) to %a3 will act on scalar(%a3) at - line 13.
615 Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 14.
616 Applying substitution (s///) to %hash will act on scalar(%hash) at - line 15.
617 Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 16.
618 Useless use of /d modifier in transliteration operator at - line 17.
619 Replacement list is longer than search list at - line 18.
620 Can't modify array dereference in substitution (s///) at - line 6, near "s/a/b/ ;"
621 BEGIN not safe after errors--compilation aborted at - line 20.
622 ########
623 # op.c
624 use warnings 'parenthesis' ;
625 my $a, $b = (1,2);
626 my @foo,%bar,   $quux; # there's a TAB here
627 my $x, $y or print;
628 no warnings 'parenthesis' ;
629 my $c, $d = (1,2);
630 EXPECT
631 Parentheses missing around "my" list at - line 3.
632 Parentheses missing around "my" list at - line 4.
633 ########
634 # op.c
635 use warnings 'parenthesis' ;
636 our $a, $b = (1,2);
637 no warnings 'parenthesis' ;
638 our $c, $d = (1,2);
639 EXPECT
640 Parentheses missing around "our" list at - line 3.
641 ########
642 # op.c
643 use warnings 'parenthesis' ;
644 local $a, $b = (1,2);
645 local *f, *g;
646 no warnings 'parenthesis' ;
647 local $c, $d = (1,2);
648 EXPECT
649 Parentheses missing around "local" list at - line 3.
650 Parentheses missing around "local" list at - line 4.
651 ########
652 # op.c
653 use warnings 'bareword' ;
654 print (ABC || 1) ;
655 no warnings 'bareword' ;
656 print (ABC || 1) ;
657 EXPECT
658 Bareword found in conditional at - line 3.
659 ########
660 --FILE-- abc
661
662 --FILE--
663 # op.c
664 use warnings 'misc' ;
665 open FH, "<abc" ;
666 $x = 1 if $x = <FH> ;
667 no warnings 'misc' ;
668 $x = 1 if $x = <FH> ;
669 EXPECT
670 Value of <HANDLE> construct can be "0"; test with defined() at - line 4.
671 ########
672 # op.c
673 use warnings 'misc' ;
674 opendir FH, "." ;
675 $x = 1 if $x = readdir FH ;
676 no warnings 'misc' ;
677 $x = 1 if $x = readdir FH ;
678 closedir FH ;
679 EXPECT
680 Value of readdir() operator can be "0"; test with defined() at - line 4.
681 ########
682 # op.c
683 use warnings 'misc' ;
684 $x = 1 if $x = <*> ;
685 no warnings 'misc' ;
686 $x = 1 if $x = <*> ;
687 EXPECT
688 Value of glob construct can be "0"; test with defined() at - line 3.
689 ########
690 # op.c
691 use warnings 'misc' ;
692 %a = (1,2,3,4) ;
693 $x = 1 if $x = each %a ;
694 no warnings 'misc' ;
695 $x = 1 if $x = each %a ;
696 EXPECT
697 Value of each() operator can be "0"; test with defined() at - line 4.
698 ########
699 # op.c
700 use warnings 'misc' ;
701 $x = 1 while $x = <*> and 0 ;
702 no warnings 'misc' ;
703 $x = 1 while $x = <*> and 0 ;
704 EXPECT
705 Value of glob construct can be "0"; test with defined() at - line 3.
706 ########
707 # op.c
708 use warnings 'misc' ;
709 opendir FH, "." ;
710 $x = 1 while $x = readdir FH and 0 ;
711 no warnings 'misc' ;
712 $x = 1 while $x = readdir FH and 0 ;
713 closedir FH ;
714 EXPECT
715 Value of readdir() operator can be "0"; test with defined() at - line 4.
716 ########
717 # op.c
718 use warnings 'misc';
719 open FH, "<abc";
720 ($_ = <FH>) // ($_ = 1);
721 opendir DH, ".";
722 %a = (1,2,3,4) ;
723 EXPECT
724 ########
725 # op.c
726 use warnings 'redefine' ;
727 sub fred {}
728 sub fred {}
729 no warnings 'redefine' ;
730 sub fred {}
731 EXPECT
732 Subroutine fred redefined at - line 4.
733 ########
734 # op.c
735 use warnings 'redefine' ;
736 sub fred () { 1 }
737 sub fred () { 1 }
738 no warnings 'redefine' ;
739 sub fred () { 1 }
740 EXPECT
741 Constant subroutine fred redefined at - line 4.
742 ########
743 # op.c
744 sub fred () { 1 }
745 sub fred () { 2 }
746 EXPECT
747 Constant subroutine fred redefined at - line 3.
748 ########
749 # op.c
750 sub fred () { 1 }
751 *fred = sub () { 2 };
752 EXPECT
753 Constant subroutine main::fred redefined at - line 3.
754 ########
755 # op.c
756 no warnings 'redefine' ;
757 sub fred () { 1 }
758 sub fred () { 2 }
759 EXPECT
760 ########
761 # op.c
762 no warnings 'redefine' ;
763 sub fred () { 1 }
764 *fred = sub () { 2 };
765 EXPECT
766 ########
767 # op.c
768 use warnings 'redefine' ;
769 format FRED =
770 .
771 format FRED =
772 .
773 no warnings 'redefine' ;
774 format FRED =
775 .
776 EXPECT
777 Format FRED redefined at - line 5.
778 ########
779 # op.c
780 push FRED;
781 no warnings 'deprecated' ;
782 push FRED;
783 EXPECT
784 Array @FRED missing the @ in argument 1 of push() at - line 2.
785 ########
786 # op.c
787 @a = keys FRED ;
788 no warnings 'deprecated' ;
789 @a = keys FRED ;
790 EXPECT
791 Hash %FRED missing the % in argument 1 of keys() at - line 2.
792 ########
793 # op.c
794 use warnings 'syntax' ;
795 exec "$^X -e 1" ; 
796 my $a
797 EXPECT
798 Statement unlikely to be reached at - line 4.
799         (Maybe you meant system() when you said exec()?)
800 ########
801 # op.c, no warning if exec isn't a statement.
802 use warnings 'syntax' ;
803 $a || exec "$^X -e 1" ;
804 my $a
805 EXPECT
806 ########
807 # op.c
808 defined(@a);
809 EXPECT
810 defined(@array) is deprecated at - line 2.
811         (Maybe you should just omit the defined()?)
812 ########
813 # op.c
814 my @a; defined(@a);
815 EXPECT
816 defined(@array) is deprecated at - line 2.
817         (Maybe you should just omit the defined()?)
818 ########
819 # op.c
820 defined(@a = (1,2,3));
821 EXPECT
822 defined(@array) is deprecated at - line 2.
823         (Maybe you should just omit the defined()?)
824 ########
825 # op.c
826 defined(%h);
827 EXPECT
828 defined(%hash) is deprecated at - line 2.
829         (Maybe you should just omit the defined()?)
830 ########
831 # op.c
832 my %h; defined(%h);
833 EXPECT
834 defined(%hash) is deprecated at - line 2.
835         (Maybe you should just omit the defined()?)
836 ########
837 # op.c
838 no warnings 'syntax' ;
839 exec "$^X -e 1" ; 
840 my $a
841 EXPECT
842
843 ########
844 # op.c
845 sub fred();
846 sub fred($) {}
847 EXPECT
848 Prototype mismatch: sub main::fred () vs ($) at - line 3.
849 ########
850 # op.c
851 use utf8;
852 use open qw( :utf8 :std );
853 sub frèd();
854 sub frèd($) {}
855 EXPECT
856 Prototype mismatch: sub main::frèd () vs ($) at - line 5.
857 ########
858 # op.c
859 use utf8;
860 use open qw( :utf8 :std );
861 use warnings;
862 eval "sub fòò (\$\0) {}";
863 EXPECT
864 Illegal character in prototype for main::fòò : $\0 at (eval 1) line 1.
865 ########
866 # op.c
867 use utf8;
868 use open qw( :utf8 :std );
869 use warnings;
870 eval "sub foo (\0) {}";
871 EXPECT
872 Illegal character in prototype for main::foo : \0 at (eval 1) line 1.
873 ########
874 # op.c
875 use utf8;
876 use open qw( :utf8 :std );
877 use warnings;
878 BEGIN { $::{"foo"} = "\$\0L\351on" }
879 BEGIN { eval "sub foo (\$\0L\x{c3}\x{a9}on) {}"; }
880 EXPECT
881 Illegal character in prototype for main::foo : $\x{0}L... at (eval 1) line 1.
882 ########
883 # op.c
884 use utf8;
885 use open qw( :utf8 :std );
886 use warnings;
887 BEGIN { eval "sub foo (\0) {}"; }
888 EXPECT
889 Illegal character in prototype for main::foo : \0 at (eval 1) line 1.
890 ########
891 # op.c
892 use warnings;
893 eval "sub foo (\xAB) {}";
894 EXPECT
895 Illegal character in prototype for main::foo : \x{ab} at (eval 1) line 1.
896 ########
897 # op.c
898 use utf8;
899 use open qw( :utf8 :std );
900 use warnings;
901 BEGIN { eval "sub foo (\x{30cb}) {}"; }
902 EXPECT
903 Illegal character in prototype for main::foo : \x{30cb} at (eval 1) line 1.
904 ########
905 # op.c
906 use utf8;
907 use open qw( :utf8 :std );
908 use warnings;
909 BEGIN { $::{"foo"} = "\x{30cb}" }
910 BEGIN { eval "sub foo {}"; }
911 EXPECT
912 Prototype mismatch: sub main::foo (ニ) vs none at (eval 1) line 1.
913 ########
914 # op.c
915 $^W = 0 ;
916 sub fred() ;
917 sub fred($) {}
918 {
919     no warnings 'prototype' ;
920     sub Fred() ;
921     sub Fred($) {}
922     use warnings 'prototype' ;
923     sub freD() ;
924     sub freD($) {}
925 }
926 sub FRED() ;
927 sub FRED($) {}
928 EXPECT
929 Prototype mismatch: sub main::fred () vs ($) at - line 4.
930 Prototype mismatch: sub main::freD () vs ($) at - line 11.
931 Prototype mismatch: sub main::FRED () vs ($) at - line 14.
932 ########
933 # op.c [S_simplify_sort]
934 # [perl #86136]
935 my @tests = split /^/, '
936   sort {$a <=> $b} @a;
937   sort {$a cmp $b} @a;
938   { use integer; sort {$a <=> $b} @a}
939   sort {$b <=> $a} @a;
940   sort {$b cmp $a} @a;
941   { use integer; sort {$b <=> $a} @a}
942 ';
943 for my $pragma ('use warnings "syntax";', '') {
944   for my $vars ('', 'my $a;', 'my $b;', 'my ($a,$b);') {
945     for my $inner_stmt ('', 'print;', 'func();') {
946       eval "#line " . ++$line . "01 -\n$pragma\n$vars"
947           . join "", map s/sort \{\K/$inner_stmt/r, @tests;
948       $@ and die;
949     }
950   }
951 }
952 sub func{}
953 use warnings 'syntax';
954 my $a;
955 # These used to be errors!
956 sort { ; } $a <=> $b;
957 sort { ; } $a, "<=>";
958 sort { ; } $a, $cmp;
959 sort $a, $b if $cmpany_name;
960 sort if $a + $cmp;
961 sort @t; $a + $cmp;
962 EXPECT
963 "my $a" used in sort comparison at - line 403.
964 "my $a" used in sort comparison at - line 404.
965 "my $a" used in sort comparison at - line 405.
966 "my $a" used in sort comparison at - line 406.
967 "my $a" used in sort comparison at - line 407.
968 "my $a" used in sort comparison at - line 408.
969 "my $a" used in sort comparison at - line 503.
970 "my $a" used in sort comparison at - line 504.
971 "my $a" used in sort comparison at - line 505.
972 "my $a" used in sort comparison at - line 506.
973 "my $a" used in sort comparison at - line 507.
974 "my $a" used in sort comparison at - line 508.
975 "my $a" used in sort comparison at - line 603.
976 "my $a" used in sort comparison at - line 604.
977 "my $a" used in sort comparison at - line 605.
978 "my $a" used in sort comparison at - line 606.
979 "my $a" used in sort comparison at - line 607.
980 "my $a" used in sort comparison at - line 608.
981 "my $b" used in sort comparison at - line 703.
982 "my $b" used in sort comparison at - line 704.
983 "my $b" used in sort comparison at - line 705.
984 "my $b" used in sort comparison at - line 706.
985 "my $b" used in sort comparison at - line 707.
986 "my $b" used in sort comparison at - line 708.
987 "my $b" used in sort comparison at - line 803.
988 "my $b" used in sort comparison at - line 804.
989 "my $b" used in sort comparison at - line 805.
990 "my $b" used in sort comparison at - line 806.
991 "my $b" used in sort comparison at - line 807.
992 "my $b" used in sort comparison at - line 808.
993 "my $b" used in sort comparison at - line 903.
994 "my $b" used in sort comparison at - line 904.
995 "my $b" used in sort comparison at - line 905.
996 "my $b" used in sort comparison at - line 906.
997 "my $b" used in sort comparison at - line 907.
998 "my $b" used in sort comparison at - line 908.
999 "my $a" used in sort comparison at - line 1003.
1000 "my $b" used in sort comparison at - line 1003.
1001 "my $a" used in sort comparison at - line 1004.
1002 "my $b" used in sort comparison at - line 1004.
1003 "my $a" used in sort comparison at - line 1005.
1004 "my $b" used in sort comparison at - line 1005.
1005 "my $b" used in sort comparison at - line 1006.
1006 "my $a" used in sort comparison at - line 1006.
1007 "my $b" used in sort comparison at - line 1007.
1008 "my $a" used in sort comparison at - line 1007.
1009 "my $b" used in sort comparison at - line 1008.
1010 "my $a" used in sort comparison at - line 1008.
1011 "my $a" used in sort comparison at - line 1103.
1012 "my $b" used in sort comparison at - line 1103.
1013 "my $a" used in sort comparison at - line 1104.
1014 "my $b" used in sort comparison at - line 1104.
1015 "my $a" used in sort comparison at - line 1105.
1016 "my $b" used in sort comparison at - line 1105.
1017 "my $b" used in sort comparison at - line 1106.
1018 "my $a" used in sort comparison at - line 1106.
1019 "my $b" used in sort comparison at - line 1107.
1020 "my $a" used in sort comparison at - line 1107.
1021 "my $b" used in sort comparison at - line 1108.
1022 "my $a" used in sort comparison at - line 1108.
1023 "my $a" used in sort comparison at - line 1203.
1024 "my $b" used in sort comparison at - line 1203.
1025 "my $a" used in sort comparison at - line 1204.
1026 "my $b" used in sort comparison at - line 1204.
1027 "my $a" used in sort comparison at - line 1205.
1028 "my $b" used in sort comparison at - line 1205.
1029 "my $b" used in sort comparison at - line 1206.
1030 "my $a" used in sort comparison at - line 1206.
1031 "my $b" used in sort comparison at - line 1207.
1032 "my $a" used in sort comparison at - line 1207.
1033 "my $b" used in sort comparison at - line 1208.
1034 "my $a" used in sort comparison at - line 1208.
1035 ########
1036 # op.c [S_simplify_sort]
1037 use warnings 'syntax'; use 5.01;
1038 state $a;
1039 sort { $a <=> $b } ();
1040 EXPECT
1041 "state $a" used in sort comparison at - line 4.
1042 ########
1043 # op.c [Perl_ck_cmp]
1044 use warnings 'syntax' ;
1045 no warnings 'deprecated';
1046 @a = $[ < 5;
1047 @a = $[ > 5;
1048 @a = $[ <= 5;
1049 @a = $[ >= 5;
1050 @a = 42 < $[;
1051 @a = 42 > $[;
1052 @a = 42 <= $[;
1053 @a = 42 >= $[;
1054 use integer;
1055 @a = $[ < 5;
1056 @a = $[ > 5;
1057 @a = $[ <= 5;
1058 @a = $[ >= 5;
1059 @a = 42 < $[;
1060 @a = 42 > $[;
1061 @a = 42 <= $[;
1062 @a = 42 >= $[;
1063 no integer;
1064 @a = $[ < $5;
1065 @a = $[ > $5;
1066 @a = $[ <= $5;
1067 @a = $[ >= $5;
1068 @a = $42 < $[;
1069 @a = $42 > $[;
1070 @a = $42 <= $[;
1071 @a = $42 >= $[;
1072 use integer;
1073 @a = $[ < $5;
1074 @a = $[ > $5;
1075 @a = $[ <= $5;
1076 @a = $[ >= $5;
1077 @a = $42 < $[;
1078 @a = $42 > $[;
1079 @a = $42 <= $[;
1080 @a = $42 >= $[;
1081 EXPECT
1082 $[ used in numeric lt (<) (did you mean $] ?) at - line 4.
1083 $[ used in numeric gt (>) (did you mean $] ?) at - line 5.
1084 $[ used in numeric le (<=) (did you mean $] ?) at - line 6.
1085 $[ used in numeric ge (>=) (did you mean $] ?) at - line 7.
1086 $[ used in numeric lt (<) (did you mean $] ?) at - line 8.
1087 $[ used in numeric gt (>) (did you mean $] ?) at - line 9.
1088 $[ used in numeric le (<=) (did you mean $] ?) at - line 10.
1089 $[ used in numeric ge (>=) (did you mean $] ?) at - line 11.
1090 $[ used in numeric lt (<) (did you mean $] ?) at - line 13.
1091 $[ used in numeric gt (>) (did you mean $] ?) at - line 14.
1092 $[ used in numeric le (<=) (did you mean $] ?) at - line 15.
1093 $[ used in numeric ge (>=) (did you mean $] ?) at - line 16.
1094 $[ used in numeric lt (<) (did you mean $] ?) at - line 17.
1095 $[ used in numeric gt (>) (did you mean $] ?) at - line 18.
1096 $[ used in numeric le (<=) (did you mean $] ?) at - line 19.
1097 $[ used in numeric ge (>=) (did you mean $] ?) at - line 20.
1098 ########
1099 # op.c [Perl_ck_length]
1100 use warnings 'syntax' ;
1101 length(@a);
1102 length(%b);
1103 length(@$c);
1104 length(%$d);
1105 length($a);
1106 length(my %h);
1107 length(my @g);
1108 EXPECT
1109 length() used on @a (did you mean "scalar(@a)"?) at - line 3.
1110 length() used on %b (did you mean "scalar(keys %b)"?) at - line 4.
1111 length() used on @array (did you mean "scalar(@array)"?) at - line 5.
1112 length() used on %hash (did you mean "scalar(keys %hash)"?) at - line 6.
1113 length() used on %h (did you mean "scalar(keys %h)"?) at - line 8.
1114 length() used on @g (did you mean "scalar(@g)"?) at - line 9.
1115 ########
1116 # op.c
1117 use warnings 'syntax' ;
1118 join /---/, 'x', 'y', 'z';
1119 EXPECT
1120 /---/ should probably be written as "---" at - line 3.
1121 ########
1122 # op.c
1123 use utf8;
1124 use open qw( :utf8 :std );
1125 use warnings 'syntax' ;
1126 join /~~~/, 'x', 'y', 'z';
1127 EXPECT
1128 /~~~/ should probably be written as "~~~" at - line 5.
1129 ########
1130 # op.c [Perl_peep]
1131 use warnings 'prototype' ;
1132 fred() ; 
1133 sub fred ($$) {}
1134 no warnings 'prototype' ;
1135 joe() ; 
1136 sub joe ($$) {}
1137 EXPECT
1138 main::fred() called too early to check prototype at - line 3.
1139 ########
1140 # op.c [Perl_newATTRSUB]
1141 --FILE-- abc.pm
1142 use warnings 'void' ;
1143 BEGIN { $| = 1; print "in begin\n"; }
1144 CHECK { print "in check\n"; }
1145 INIT { print "in init\n"; }
1146 END { print "in end\n"; }
1147 print "in mainline\n";
1148 1;
1149 --FILE--
1150 use abc;
1151 delete $INC{"abc.pm"};
1152 require abc;
1153 do "abc.pm";
1154 EXPECT
1155 in begin
1156 in mainline
1157 in check
1158 in init
1159 in begin
1160 Too late to run CHECK block at abc.pm line 3.
1161 Too late to run INIT block at abc.pm line 4.
1162 in mainline
1163 in begin
1164 Too late to run CHECK block at abc.pm line 3.
1165 Too late to run INIT block at abc.pm line 4.
1166 in mainline
1167 in end
1168 in end
1169 in end
1170 ########
1171 # op.c [Perl_newATTRSUB]
1172 --FILE-- abc.pm
1173 no warnings 'void' ;
1174 BEGIN { $| = 1; print "in begin\n"; }
1175 CHECK { print "in check\n"; }
1176 INIT { print "in init\n"; }
1177 END { print "in end\n"; }
1178 print "in mainline\n";
1179 1;
1180 --FILE--
1181 require abc;
1182 do "abc.pm";
1183 EXPECT
1184 in begin
1185 in mainline
1186 in begin
1187 in mainline
1188 in end
1189 in end
1190 ########
1191 # op.c
1192 my @x;
1193 use warnings 'syntax' ;
1194 push(@x);
1195 unshift(@x);
1196 no warnings 'syntax' ;
1197 push(@x);
1198 unshift(@x);
1199 EXPECT
1200 Useless use of push with no values at - line 4.
1201 Useless use of unshift with no values at - line 5.
1202 ########
1203 # op.c
1204 # 20020401 mjd@plover.com at suggestion of jfriedl@yahoo.com
1205 use warnings 'regexp';
1206 split /blah/g, "blah";
1207 no warnings 'regexp';
1208 split /blah/g, "blah";
1209 EXPECT
1210 Use of /g modifier is meaningless in split at - line 4.
1211 ########
1212 # op.c
1213 use warnings 'precedence';
1214 $a = $b & $c == $d;
1215 $a = $b ^ $c != $d;
1216 $a = $b | $c > $d;
1217 $a = $b < $c & $d;
1218 $a = $b >= $c ^ $d;
1219 $a = $b <= $c | $d;
1220 $a = $b <=> $c & $d;
1221 $a &= $b == $c; $a |= $b == $c; $a ^= $b == $c; # shouldn't warn
1222 no warnings 'precedence';
1223 $a = $b & $c == $d;
1224 $a = $b ^ $c != $d;
1225 $a = $b | $c > $d;
1226 $a = $b < $c & $d;
1227 $a = $b >= $c ^ $d;
1228 $a = $b <= $c | $d;
1229 $a = $b <=> $c & $d;
1230 EXPECT
1231 Possible precedence problem on bitwise & operator at - line 3.
1232 Possible precedence problem on bitwise ^ operator at - line 4.
1233 Possible precedence problem on bitwise | operator at - line 5.
1234 Possible precedence problem on bitwise & operator at - line 6.
1235 Possible precedence problem on bitwise ^ operator at - line 7.
1236 Possible precedence problem on bitwise | operator at - line 8.
1237 Possible precedence problem on bitwise & operator at - line 9.
1238 ########
1239 # op.c
1240 use integer;
1241 use warnings 'precedence';
1242 $a = $b & $c == $d;
1243 $a = $b ^ $c != $d;
1244 $a = $b | $c > $d;
1245 $a = $b < $c & $d;
1246 $a = $b >= $c ^ $d;
1247 $a = $b <= $c | $d;
1248 $a = $b <=> $c & $d;
1249 no warnings 'precedence';
1250 $a = $b & $c == $d;
1251 $a = $b ^ $c != $d;
1252 $a = $b | $c > $d;
1253 $a = $b < $c & $d;
1254 $a = $b >= $c ^ $d;
1255 $a = $b <= $c | $d;
1256 $a = $b <=> $c & $d;
1257 EXPECT
1258 Possible precedence problem on bitwise & operator at - line 4.
1259 Possible precedence problem on bitwise ^ operator at - line 5.
1260 Possible precedence problem on bitwise | operator at - line 6.
1261 Possible precedence problem on bitwise & operator at - line 7.
1262 Possible precedence problem on bitwise ^ operator at - line 8.
1263 Possible precedence problem on bitwise | operator at - line 9.
1264 Possible precedence problem on bitwise & operator at - line 10.
1265 ########
1266 # op.c
1267
1268 # ok    => local() has desired effect;
1269 # ignore=> local() silently ignored
1270
1271 use warnings 'syntax';
1272
1273 local(undef);           # OP_UNDEF              ignore
1274 sub lval : lvalue {};
1275 local(lval());          # OP_ENTERSUB
1276 local($x **= 1);        # OP_POW
1277 local($x *=  1);        # OP_MULTIPLY
1278 local($x /=  1);        # OP_DIVIDE
1279 local($x %=  1);        # OP_MODULO
1280 local($x x=  1);        # OP_REPEAT
1281 local($x +=  1);        # OP_ADD
1282 local($x -=  1);        # OP_SUBTRACT
1283 local($x .=  1);        # OP_CONCAT
1284 local($x <<= 1);        # OP_LEFT_SHIFT
1285 local($x >>= 1);        # OP_RIGHT_SHIFT
1286 local($x &=  1);        # OP_BIT_AND
1287 local($x ^=  1);        # OP_BIT_XOR
1288 local($x |=  1);        # OP_BIT_OR
1289 {
1290     use integer;
1291     local($x *= 1);     # OP_I_MULTIPLY
1292     local($x /= 1);     # OP_I_DIVIDE
1293     local($x %= 1);     # OP_I_MODULO
1294     local($x += 1);     # OP_I_ADD
1295     local($x -= 1);     # OP_I_SUBTRACT
1296 }
1297 local($x?$y:$z) = 1;    # OP_COND_EXPR          ok
1298 # these two are fatal run-time errors instead
1299 #local(@$a);            # OP_RV2AV              ok
1300 #local(%$a);            # OP_RV2HV              ok
1301 local(*a);              # OP_RV2GV              ok
1302 local(@a[1,2]);         # OP_ASLICE             ok
1303 local(@a{1,2});         # OP_HSLICE             ok
1304 local(@a = (1,2));      # OP_AASSIGN
1305 local($$x);             # OP_RV2SV              ok
1306 local($#a);             # OP_AV2ARYLEN
1307 local($x =   1);        # OP_SASSIGN
1308 local($x &&= 1);        # OP_ANDASSIGN
1309 local($x ||= 1);        # OP_ORASSIGN
1310 local($x //= 1);        # OP_DORASSIGN
1311 local($a[0]);           # OP_AELEMFAST          ok
1312
1313 local(substr($x,0,1));  # OP_SUBSTR
1314 local(pos($x));         # OP_POS
1315 local(vec($x,0,1));     # OP_VEC
1316 local($a[$b]);          # OP_AELEM              ok
1317 local($a{$b});          # OP_HELEM              ok
1318
1319 no warnings 'syntax';
1320 EXPECT
1321 Useless localization of subroutine entry at - line 10.
1322 Useless localization of exponentiation (**) at - line 11.
1323 Useless localization of multiplication (*) at - line 12.
1324 Useless localization of division (/) at - line 13.
1325 Useless localization of modulus (%) at - line 14.
1326 Useless localization of repeat (x) at - line 15.
1327 Useless localization of addition (+) at - line 16.
1328 Useless localization of subtraction (-) at - line 17.
1329 Useless localization of concatenation (.) or string at - line 18.
1330 Useless localization of left bitshift (<<) at - line 19.
1331 Useless localization of right bitshift (>>) at - line 20.
1332 Useless localization of bitwise and (&) at - line 21.
1333 Useless localization of bitwise xor (^) at - line 22.
1334 Useless localization of bitwise or (|) at - line 23.
1335 Useless localization of integer multiplication (*) at - line 26.
1336 Useless localization of integer division (/) at - line 27.
1337 Useless localization of integer modulus (%) at - line 28.
1338 Useless localization of integer addition (+) at - line 29.
1339 Useless localization of integer subtraction (-) at - line 30.
1340 Useless localization of list assignment at - line 39.
1341 Useless localization of array length at - line 41.
1342 Useless localization of scalar assignment at - line 42.
1343 Useless localization of logical and assignment (&&=) at - line 43.
1344 Useless localization of logical or assignment (||=) at - line 44.
1345 Useless localization of defined or assignment (//=) at - line 45.
1346 Useless localization of substr at - line 48.
1347 Useless localization of match position at - line 49.
1348 Useless localization of vec at - line 50.
1349 ########
1350 # op.c
1351 my $x1 if 0;
1352 my @x2 if 0;
1353 my %x3 if 0;
1354 my ($x4) if 0;
1355 my ($x5,@x6, %x7) if 0;
1356 0 && my $z1;
1357 0 && my (%z2);
1358 # these shouldn't warn
1359 our $x if 0;
1360 our $x unless 0;
1361 if (0) { my $w1 }
1362 if (my $w2) { $a=1 }
1363 if ($a && (my $w3 = 1)) {$a = 2}
1364
1365 EXPECT
1366 Deprecated use of my() in false conditional at - line 2.
1367 Deprecated use of my() in false conditional at - line 3.
1368 Deprecated use of my() in false conditional at - line 4.
1369 Deprecated use of my() in false conditional at - line 5.
1370 Deprecated use of my() in false conditional at - line 6.
1371 Deprecated use of my() in false conditional at - line 7.
1372 Deprecated use of my() in false conditional at - line 8.
1373 ########
1374 # op.c
1375 $[ = 1;
1376 ($[) = 1;
1377 use warnings 'deprecated';
1378 $[ = 2;
1379 ($[) = 2;
1380 no warnings 'deprecated';
1381 $[ = 3;
1382 ($[) = 3;
1383 EXPECT
1384 Use of assignment to $[ is deprecated at - line 2.
1385 Use of assignment to $[ is deprecated at - line 3.
1386 Use of assignment to $[ is deprecated at - line 5.
1387 Use of assignment to $[ is deprecated at - line 6.
1388 ########
1389 # op.c
1390 use warnings 'void';
1391 @x = split /y/, "z";
1392 $x = split /y/, "z";
1393      split /y/, "z";
1394 no warnings 'void';
1395 @x = split /y/, "z";
1396 $x = split /y/, "z";
1397      split /y/, "z";
1398 EXPECT
1399 Useless use of split in void context at - line 5.
1400 ########
1401 # op.c
1402 use warnings 'redefine' ;
1403 use utf8;
1404 use open qw( :utf8 :std );
1405 sub frèd {}
1406 sub frèd {}
1407 no warnings 'redefine' ;
1408 sub frèd {}
1409 EXPECT
1410 Subroutine frèd redefined at - line 6.
1411 ########
1412 # op.c
1413 use warnings 'redefine' ;
1414 use utf8;
1415 use open qw( :utf8 :std );
1416 sub frèd () { 1 }
1417 sub frèd () { 1 }
1418 no warnings 'redefine' ;
1419 sub frèd () { 1 }
1420 EXPECT
1421 Constant subroutine frèd redefined at - line 6.
1422 ########
1423 # op.c
1424 use utf8;
1425 use open qw( :utf8 :std );
1426 sub frèd () { 1 }
1427 sub frèd () { 2 }
1428 EXPECT
1429 Constant subroutine frèd redefined at - line 5.
1430 ########
1431 # op.c
1432 use utf8;
1433 use open qw( :utf8 :std );
1434 sub frèd () { 1 }
1435 *frèd = sub () { 2 };
1436 EXPECT
1437 Constant subroutine main::frèd redefined at - line 5.
1438 ########
1439 # op.c
1440 use warnings 'redefine' ;
1441 use utf8;
1442 use open qw( :utf8 :std );
1443 sub ᚠርƊ {}
1444 sub ᚠርƊ {}
1445 no warnings 'redefine' ;
1446 sub ᚠርƊ {}
1447 EXPECT
1448 Subroutine ᚠርƊ redefined at - line 6.
1449 ########
1450 # op.c
1451 use warnings 'redefine' ;
1452 use utf8;
1453 use open qw( :utf8 :std );
1454 sub ᚠርƊ () { 1 }
1455 sub ᚠርƊ () { 1 }
1456 no warnings 'redefine' ;
1457 sub ᚠርƊ () { 1 }
1458 EXPECT
1459 Constant subroutine ᚠርƊ redefined at - line 6.
1460 ########
1461 # op.c
1462 use utf8;
1463 use open qw( :utf8 :std );
1464 sub ᚠርƊ () { 1 }
1465 sub ᚠርƊ () { 2 }
1466 EXPECT
1467 Constant subroutine ᚠርƊ redefined at - line 5.
1468 ########
1469 # op.c
1470 use utf8;
1471 use open qw( :utf8 :std );
1472 sub ᚠርƊ () { 1 }
1473 *ᚠርƊ = sub () { 2 };
1474 EXPECT
1475 Constant subroutine main::ᚠርƊ redefined at - line 5.
1476 ########