prototype() didn't warn when used in void context.
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / op
1   op.c          AOK
2
3      "my" variable %s masks earlier declaration in same scope
4         my $x;
5         my $x ;
6
7      Variable "%s" may be unavailable 
8         sub x {
9             my $x;
10             sub y {
11                 $x
12             }
13         }
14
15      Variable "%s" will not stay shared 
16         sub x {
17             my $x;
18             sub y {
19                 sub { $x }
20             }
21         }
22
23      Found = in conditional, should be ==
24         1 if $a = 1 ;
25
26      Use of implicit split to @_ is deprecated
27         split ;
28
29      Use of implicit split to @_ is deprecated
30         $a = split ;
31
32      Useless use of time in void context
33      Useless use of a variable in void context
34      Useless use of a constant in void context
35         time ;
36         $a ;
37         "abc"
38
39      Useless use of sort in scalar context
40         my $x = sort (2,1,3);
41
42      Applying %s to %s will act on scalar(%s)
43         my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
44         @a =~ /abc/ ;
45         @a =~ s/a/b/ ;
46         @a =~ tr/a/b/ ;
47         @$b =~ /abc/ ;
48         @$b =~ s/a/b/ ;
49         @$b =~ tr/a/b/ ;
50         %a =~ /abc/ ;
51         %a =~ s/a/b/ ;
52         %a =~ tr/a/b/ ;
53         %$c =~ /abc/ ;
54         %$c =~ s/a/b/ ;
55         %$c =~ tr/a/b/ ;
56
57
58      Parentheses missing around "my" list at -e line 1.
59        my $a, $b = (1,2);
60  
61      Parentheses missing around "local" list at -e line 1.
62        local $a, $b = (1,2);
63  
64      Bareword found in conditional at -e line 1.
65        use warnings 'bareword'; my $x = print(ABC || 1);
66  
67      Value of %s may be \"0\"; use \"defined\" 
68         $x = 1 if $x = <FH> ;
69         $x = 1 while $x = <FH> ;
70
71      Subroutine fred redefined at -e line 1.
72        sub fred{1;} sub fred{1;}
73  
74      Constant subroutine %s redefined 
75         sub fred() {1;} sub fred() {1;}
76  
77      Format FRED redefined at /tmp/x line 5.
78        format FRED =
79        .
80        format FRED =
81        .
82  
83      Array @%s missing the @ in argument %d of %s() 
84         push fred ;
85  
86      Hash %%%s missing the %% in argument %d of %s() 
87         keys joe ;
88  
89      Statement unlikely to be reached
90         (Maybe you meant system() when you said exec()?
91         exec "true" ; my $a
92
93      defined(@array) is deprecated
94         (Maybe you should just omit the defined()?)
95         my @a ; defined @a ;
96         defined (@a = (1,2,3)) ;
97
98      defined(%hash) is deprecated
99         (Maybe you should just omit the defined()?)
100         my %h ; defined %h ;
101     
102      /---/ should probably be written as "---"
103         join(/---/, @foo);
104
105     %s() called too early to check prototype            [Perl_peep]
106         fred() ; sub fred ($$) {}
107
108
109     Package `%s' not found (did you use the incorrect case?)
110
111     Use of /g modifier is meaningless in split
112
113     Possible precedence problem on bitwise %c operator  [Perl_ck_bitop]
114
115     Mandatory Warnings 
116     ------------------
117     Prototype mismatch:         [cv_ckproto]
118         sub fred() ;
119         sub fred($) {}
120
121     %s never introduced         [pad_leavemy]   TODO
122     Runaway prototype           [newSUB]        TODO
123     oops: oopsAV                [oopsAV]        TODO
124     oops: oopsHV                [oopsHV]        TODO
125     
126 __END__
127 # op.c
128 use warnings 'misc' ;
129 my $x ;
130 my $x ;
131 my $y = my $y ;
132 no warnings 'misc' ;
133 my $x ;
134 my $y ;
135 EXPECT
136 "my" variable $x masks earlier declaration in same scope at - line 4.
137 "my" variable $y masks earlier declaration in same statement at - line 5.
138 ########
139 # op.c
140 use warnings 'closure' ;
141 sub x {
142       my $x;
143       sub y {
144          $x
145       }
146    }
147 EXPECT
148 Variable "$x" will not stay shared at - line 7.
149 ########
150 # op.c
151 no warnings 'closure' ;
152 sub x {
153       my $x;
154       sub y {
155          $x
156       }
157    }
158 EXPECT
159
160 ########
161 # op.c
162 use warnings 'closure' ;
163 sub x {
164       our $x;
165       sub y {
166          $x
167       }
168    }
169 EXPECT
170
171 ########
172 # op.c
173 use warnings 'closure' ;
174 sub x {
175       my $x;
176       sub y {
177          sub { $x }
178       }
179    }
180 EXPECT
181 Variable "$x" may be unavailable at - line 6.
182 ########
183 # op.c
184 no warnings 'closure' ;
185 sub x {
186       my $x;
187       sub y {
188          sub { $x }
189       }
190    }
191 EXPECT
192
193 ########
194 # op.c
195 use warnings 'syntax' ;
196 1 if $a = 1 ;
197 no warnings 'syntax' ;
198 1 if $a = 1 ;
199 EXPECT
200 Found = in conditional, should be == at - line 3.
201 ########
202 # op.c
203 use warnings 'deprecated' ;
204 split ;
205 no warnings 'deprecated' ;
206 split ;
207 EXPECT
208 Use of implicit split to @_ is deprecated at - line 3.
209 ########
210 # op.c
211 use warnings 'deprecated' ;
212 $a = split ;
213 no warnings 'deprecated' ;
214 $a = split ;
215 EXPECT
216 Use of implicit split to @_ is deprecated at - line 3.
217 ########
218 # op.c
219 use warnings 'deprecated';
220 my (@foo, %foo);
221 %main::foo->{"bar"};
222 %foo->{"bar"};
223 @main::foo->[23];
224 @foo->[23];
225 $main::foo = {}; %$main::foo->{"bar"};
226 $foo = {}; %$foo->{"bar"};
227 $main::foo = []; @$main::foo->[34];
228 $foo = []; @$foo->[34];
229 no warnings 'deprecated';
230 %main::foo->{"bar"};
231 %foo->{"bar"};
232 @main::foo->[23];
233 @foo->[23];
234 $main::foo = {}; %$main::foo->{"bar"};
235 $foo = {}; %$foo->{"bar"};
236 $main::foo = []; @$main::foo->[34];
237 $foo = []; @$foo->[34];
238 EXPECT
239 Using a hash as a reference is deprecated at - line 4.
240 Using a hash as a reference is deprecated at - line 5.
241 Using an array as a reference is deprecated at - line 6.
242 Using an array as a reference is deprecated at - line 7.
243 Using a hash as a reference is deprecated at - line 8.
244 Using a hash as a reference is deprecated at - line 9.
245 Using an array as a reference is deprecated at - line 10.
246 Using an array as a reference is deprecated at - line 11.
247 ########
248 # op.c
249 use warnings 'void' ; close STDIN ;
250 1 x 3 ;                 # OP_REPEAT
251                         # OP_GVSV
252 wantarray ;             # OP_WANTARRAY
253                         # OP_GV
254                         # OP_PADSV
255                         # OP_PADAV
256                         # OP_PADHV
257                         # OP_PADANY
258                         # OP_AV2ARYLEN
259 ref ;                   # OP_REF
260 \@a ;                   # OP_REFGEN
261 \$a ;                   # OP_SREFGEN
262 defined $a ;            # OP_DEFINED
263 hex $a ;                # OP_HEX
264 oct $a ;                # OP_OCT
265 length $a ;             # OP_LENGTH
266 substr $a,1 ;           # OP_SUBSTR
267 vec $a,1,2 ;            # OP_VEC
268 index $a,1,2 ;          # OP_INDEX
269 rindex $a,1,2 ;         # OP_RINDEX
270 sprintf $a ;            # OP_SPRINTF
271 $a[0] ;                 # OP_AELEM
272                         # OP_AELEMFAST
273 @a[0] ;                 # OP_ASLICE
274 #values %a ;            # OP_VALUES
275 #keys %a ;              # OP_KEYS
276 $a{0} ;                 # OP_HELEM
277 @a{0} ;                 # OP_HSLICE
278 unpack "a", "a" ;       # OP_UNPACK
279 pack $a,"" ;            # OP_PACK
280 join "" ;               # OP_JOIN
281 (@a)[0,1] ;             # OP_LSLICE
282                         # OP_ANONLIST
283                         # OP_ANONHASH
284 sort(1,2) ;             # OP_SORT
285 reverse(1,2) ;          # OP_REVERSE
286                         # OP_RANGE
287                         # OP_FLIP
288 (1 ..2) ;               # OP_FLOP
289 caller ;                # OP_CALLER
290 fileno STDIN ;          # OP_FILENO
291 eof STDIN ;             # OP_EOF
292 tell STDIN ;            # OP_TELL
293 readlink 1;             # OP_READLINK
294 time ;                  # OP_TIME
295 localtime ;             # OP_LOCALTIME
296 gmtime ;                # OP_GMTIME
297 eval { getgrnam 1 };    # OP_GGRNAM
298 eval { getgrgid 1 };    # OP_GGRGID
299 eval { getpwnam 1 };    # OP_GPWNAM
300 eval { getpwuid 1 };    # OP_GPWUID
301 prototype "foo";        # OP_PROTOTYPE
302 EXPECT
303 Useless use of repeat (x) in void context at - line 3.
304 Useless use of wantarray in void context at - line 5.
305 Useless use of reference-type operator in void context at - line 12.
306 Useless use of reference constructor in void context at - line 13.
307 Useless use of single ref constructor in void context at - line 14.
308 Useless use of defined operator in void context at - line 15.
309 Useless use of hex in void context at - line 16.
310 Useless use of oct in void context at - line 17.
311 Useless use of length in void context at - line 18.
312 Useless use of substr in void context at - line 19.
313 Useless use of vec in void context at - line 20.
314 Useless use of index in void context at - line 21.
315 Useless use of rindex in void context at - line 22.
316 Useless use of sprintf in void context at - line 23.
317 Useless use of array element in void context at - line 24.
318 Useless use of array slice in void context at - line 26.
319 Useless use of hash element in void context at - line 29.
320 Useless use of hash slice in void context at - line 30.
321 Useless use of unpack in void context at - line 31.
322 Useless use of pack in void context at - line 32.
323 Useless use of join or string in void context at - line 33.
324 Useless use of list slice in void context at - line 34.
325 Useless use of sort in void context at - line 37.
326 Useless use of reverse in void context at - line 38.
327 Useless use of range (or flop) in void context at - line 41.
328 Useless use of caller in void context at - line 42.
329 Useless use of fileno in void context at - line 43.
330 Useless use of eof in void context at - line 44.
331 Useless use of tell in void context at - line 45.
332 Useless use of readlink in void context at - line 46.
333 Useless use of time in void context at - line 47.
334 Useless use of localtime in void context at - line 48.
335 Useless use of gmtime in void context at - line 49.
336 Useless use of getgrnam in void context at - line 50.
337 Useless use of getgrgid in void context at - line 51.
338 Useless use of getpwnam in void context at - line 52.
339 Useless use of getpwuid in void context at - line 53.
340 Useless use of subroutine prototype in void context at - line 54.
341 ########
342 # op.c
343 use warnings 'void' ; close STDIN ;
344 my $x = sort (2,1,3);
345 no warnings 'void' ;
346 $x = sort (2,1,3);
347 EXPECT
348 Useless use of sort in scalar context at - line 3.
349 ########
350 # op.c
351 no warnings 'void' ; close STDIN ;
352 1 x 3 ;                 # OP_REPEAT
353                         # OP_GVSV
354 wantarray ;             # OP_WANTARRAY
355                         # OP_GV
356                         # OP_PADSV
357                         # OP_PADAV
358                         # OP_PADHV
359                         # OP_PADANY
360                         # OP_AV2ARYLEN
361 ref ;                   # OP_REF
362 \@a ;                   # OP_REFGEN
363 \$a ;                   # OP_SREFGEN
364 defined $a ;            # OP_DEFINED
365 hex $a ;                # OP_HEX
366 oct $a ;                # OP_OCT
367 length $a ;             # OP_LENGTH
368 substr $a,1 ;           # OP_SUBSTR
369 vec $a,1,2 ;            # OP_VEC
370 index $a,1,2 ;          # OP_INDEX
371 rindex $a,1,2 ;         # OP_RINDEX
372 sprintf $a ;            # OP_SPRINTF
373 $a[0] ;                 # OP_AELEM
374                         # OP_AELEMFAST
375 @a[0] ;                 # OP_ASLICE
376 #values %a ;            # OP_VALUES
377 #keys %a ;              # OP_KEYS
378 $a{0} ;                 # OP_HELEM
379 @a{0} ;                 # OP_HSLICE
380 unpack "a", "a" ;       # OP_UNPACK
381 pack $a,"" ;            # OP_PACK
382 join "" ;               # OP_JOIN
383 (@a)[0,1] ;             # OP_LSLICE
384                         # OP_ANONLIST
385                         # OP_ANONHASH
386 sort(1,2) ;             # OP_SORT
387 reverse(1,2) ;          # OP_REVERSE
388                         # OP_RANGE
389                         # OP_FLIP
390 (1 ..2) ;               # OP_FLOP
391 caller ;                # OP_CALLER
392 fileno STDIN ;          # OP_FILENO
393 eof STDIN ;             # OP_EOF
394 tell STDIN ;            # OP_TELL
395 readlink 1;             # OP_READLINK
396 time ;                  # OP_TIME
397 localtime ;             # OP_LOCALTIME
398 gmtime ;                # OP_GMTIME
399 eval { getgrnam 1 };    # OP_GGRNAM
400 eval { getgrgid 1 };    # OP_GGRGID
401 eval { getpwnam 1 };    # OP_GPWNAM
402 eval { getpwuid 1 };    # OP_GPWUID
403 prototype "foo";        # OP_PROTOTYPE
404 EXPECT
405 ########
406 # op.c
407 use warnings 'void' ;
408 for (@{[0]}) { "$_" }           # check warning isn't duplicated
409 no warnings 'void' ;
410 for (@{[0]}) { "$_" }           # check warning isn't duplicated
411 EXPECT
412 Useless use of string in void context at - line 3.
413 ########
414 # op.c
415 use warnings 'void' ;
416 use Config ;
417 BEGIN {
418     if ( ! $Config{d_telldir}) {
419         print <<EOM ;
420 SKIPPED
421 # telldir not present
422 EOM
423         exit 
424     }
425 }
426 telldir 1 ;             # OP_TELLDIR
427 no warnings 'void' ;
428 telldir 1 ;             # OP_TELLDIR
429 EXPECT
430 Useless use of telldir in void context at - line 13.
431 ########
432 # op.c
433 use warnings 'void' ;
434 use Config ;
435 BEGIN {
436     if ( ! $Config{d_getppid}) {
437         print <<EOM ;
438 SKIPPED
439 # getppid not present
440 EOM
441         exit 
442     }
443 }
444 getppid ;               # OP_GETPPID
445 no warnings 'void' ;
446 getppid ;               # OP_GETPPID
447 EXPECT
448 Useless use of getppid in void context at - line 13.
449 ########
450 # op.c
451 use warnings 'void' ;
452 use Config ;
453 BEGIN {
454     if ( ! $Config{d_getpgrp}) {
455         print <<EOM ;
456 SKIPPED
457 # getpgrp not present
458 EOM
459         exit 
460     }
461 }
462 getpgrp ;               # OP_GETPGRP
463 no warnings 'void' ;
464 getpgrp ;               # OP_GETPGRP
465 EXPECT
466 Useless use of getpgrp in void context at - line 13.
467 ########
468 # op.c
469 use warnings 'void' ;
470 use Config ;
471 BEGIN {
472     if ( ! $Config{d_times}) {
473         print <<EOM ;
474 SKIPPED
475 # times not present
476 EOM
477         exit 
478     }
479 }
480 times ;                 # OP_TMS
481 no warnings 'void' ;
482 times ;                 # OP_TMS
483 EXPECT
484 Useless use of times in void context at - line 13.
485 ########
486 # op.c
487 use warnings 'void' ;
488 use Config ;
489 BEGIN {
490     if ( ! $Config{d_getprior} or $^O eq 'os2') { # Locks before fixpak22
491         print <<EOM ;
492 SKIPPED
493 # getpriority not present
494 EOM
495         exit 
496     }
497 }
498 getpriority 1,2;        # OP_GETPRIORITY
499 no warnings 'void' ;
500 getpriority 1,2;        # OP_GETPRIORITY
501 EXPECT
502 Useless use of getpriority in void context at - line 13.
503 ########
504 # op.c
505 use warnings 'void' ;
506 use Config ;
507 BEGIN {
508     if ( ! $Config{d_getlogin}) {
509         print <<EOM ;
510 SKIPPED
511 # getlogin not present
512 EOM
513         exit 
514     }
515 }
516 getlogin ;                      # OP_GETLOGIN
517 no warnings 'void' ;
518 getlogin ;                      # OP_GETLOGIN
519 EXPECT
520 Useless use of getlogin in void context at - line 13.
521 ########
522 # op.c
523 use warnings 'void' ;
524 use Config ; BEGIN {
525 if ( ! $Config{d_socket}) {
526     print <<EOM ;
527 SKIPPED
528 # getsockname not present
529 # getpeername not present
530 # gethostbyname not present
531 # gethostbyaddr not present
532 # gethostent not present
533 # getnetbyname not present
534 # getnetbyaddr not present
535 # getnetent not present
536 # getprotobyname not present
537 # getprotobynumber not present
538 # getprotoent not present
539 # getservbyname not present
540 # getservbyport not present
541 # getservent not present
542 EOM
543     exit 
544 } }
545 getsockname STDIN ;     # OP_GETSOCKNAME
546 getpeername STDIN ;     # OP_GETPEERNAME
547 gethostbyname 1 ;       # OP_GHBYNAME
548 gethostbyaddr 1,2;      # OP_GHBYADDR
549 gethostent ;            # OP_GHOSTENT
550 getnetbyname 1 ;        # OP_GNBYNAME
551 getnetbyaddr 1,2 ;      # OP_GNBYADDR
552 getnetent ;             # OP_GNETENT
553 getprotobyname 1;       # OP_GPBYNAME
554 getprotobynumber 1;     # OP_GPBYNUMBER
555 getprotoent ;           # OP_GPROTOENT
556 getservbyname 1,2;      # OP_GSBYNAME
557 getservbyport 1,2;      # OP_GSBYPORT
558 getservent ;            # OP_GSERVENT
559
560 no warnings 'void' ;
561 getsockname STDIN ;     # OP_GETSOCKNAME
562 getpeername STDIN ;     # OP_GETPEERNAME
563 gethostbyname 1 ;       # OP_GHBYNAME
564 gethostbyaddr 1,2;      # OP_GHBYADDR
565 gethostent ;            # OP_GHOSTENT
566 getnetbyname 1 ;        # OP_GNBYNAME
567 getnetbyaddr 1,2 ;      # OP_GNBYADDR
568 getnetent ;             # OP_GNETENT
569 getprotobyname 1;       # OP_GPBYNAME
570 getprotobynumber 1;     # OP_GPBYNUMBER
571 getprotoent ;           # OP_GPROTOENT
572 getservbyname 1,2;      # OP_GSBYNAME
573 getservbyport 1,2;      # OP_GSBYPORT
574 getservent ;            # OP_GSERVENT
575 INIT {
576    # some functions may not be there, so we exit without running
577    exit;
578 }
579 EXPECT
580 Useless use of getsockname in void context at - line 24.
581 Useless use of getpeername in void context at - line 25.
582 Useless use of gethostbyname in void context at - line 26.
583 Useless use of gethostbyaddr in void context at - line 27.
584 Useless use of gethostent in void context at - line 28.
585 Useless use of getnetbyname in void context at - line 29.
586 Useless use of getnetbyaddr in void context at - line 30.
587 Useless use of getnetent in void context at - line 31.
588 Useless use of getprotobyname in void context at - line 32.
589 Useless use of getprotobynumber in void context at - line 33.
590 Useless use of getprotoent in void context at - line 34.
591 Useless use of getservbyname in void context at - line 35.
592 Useless use of getservbyport in void context at - line 36.
593 Useless use of getservent in void context at - line 37.
594 ########
595 # op.c
596 use warnings 'void' ;
597 *a ; # OP_RV2GV
598 $a ; # OP_RV2SV
599 @a ; # OP_RV2AV
600 %a ; # OP_RV2HV
601 no warnings 'void' ;
602 *a ; # OP_RV2GV
603 $a ; # OP_RV2SV
604 @a ; # OP_RV2AV
605 %a ; # OP_RV2HV
606 EXPECT
607 Useless use of a variable in void context at - line 3.
608 Useless use of a variable in void context at - line 4.
609 Useless use of a variable in void context at - line 5.
610 Useless use of a variable in void context at - line 6.
611 ########
612 # op.c
613 use warnings 'void' ;
614 "abc"; # OP_CONST
615 7 ; # OP_CONST
616 no warnings 'void' ;
617 "abc"; # OP_CONST
618 7 ; # OP_CONST
619 EXPECT
620 Useless use of a constant in void context at - line 3.
621 Useless use of a constant in void context at - line 4.
622 ########
623 # op.c
624 #
625 use warnings 'misc' ;
626 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
627 @a =~ /abc/ ;
628 @a =~ s/a/b/ ;
629 @a =~ tr/a/b/ ;
630 @$b =~ /abc/ ;
631 @$b =~ s/a/b/ ;
632 @$b =~ tr/a/b/ ;
633 %a =~ /abc/ ;
634 %a =~ s/a/b/ ;
635 %a =~ tr/a/b/ ;
636 %$c =~ /abc/ ;
637 %$c =~ s/a/b/ ;
638 %$c =~ tr/a/b/ ;
639 {
640 no warnings 'misc' ;
641 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
642 @a =~ /abc/ ;
643 @a =~ s/a/b/ ;
644 @a =~ tr/a/b/ ;
645 @$b =~ /abc/ ;
646 @$b =~ s/a/b/ ;
647 @$b =~ tr/a/b/ ;
648 %a =~ /abc/ ;
649 %a =~ s/a/b/ ;
650 %a =~ tr/a/b/ ;
651 %$c =~ /abc/ ;
652 %$c =~ s/a/b/ ;
653 %$c =~ tr/a/b/ ;
654 }
655 EXPECT
656 Applying pattern match (m//) to @array will act on scalar(@array) at - line 5.
657 Applying substitution (s///) to @array will act on scalar(@array) at - line 6.
658 Applying transliteration (tr///) to @array will act on scalar(@array) at - line 7.
659 Applying pattern match (m//) to @array will act on scalar(@array) at - line 8.
660 Applying substitution (s///) to @array will act on scalar(@array) at - line 9.
661 Applying transliteration (tr///) to @array will act on scalar(@array) at - line 10.
662 Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 11.
663 Applying substitution (s///) to %hash will act on scalar(%hash) at - line 12.
664 Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 13.
665 Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 14.
666 Applying substitution (s///) to %hash will act on scalar(%hash) at - line 15.
667 Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 16.
668 Can't modify private array in substitution (s///) at - line 6, near "s/a/b/ ;"
669 BEGIN not safe after errors--compilation aborted at - line 18.
670 ########
671 # op.c
672 use warnings 'syntax' ;
673 my $a, $b = (1,2);
674 no warnings 'syntax' ;
675 my $c, $d = (1,2);
676 EXPECT
677 Parentheses missing around "my" list at - line 3.
678 ########
679 # op.c
680 use warnings 'syntax' ;
681 local $a, $b = (1,2);
682 no warnings 'syntax' ;
683 local $c, $d = (1,2);
684 EXPECT
685 Parentheses missing around "local" list at - line 3.
686 ########
687 # op.c
688 use warnings 'bareword' ;
689 print (ABC || 1) ;
690 no warnings 'bareword' ;
691 print (ABC || 1) ;
692 EXPECT
693 Bareword found in conditional at - line 3.
694 ########
695 --FILE-- abc
696
697 --FILE--
698 # op.c
699 use warnings 'misc' ;
700 open FH, "<abc" ;
701 $x = 1 if $x = <FH> ;
702 no warnings 'misc' ;
703 $x = 1 if $x = <FH> ;
704 EXPECT
705 Value of <HANDLE> construct can be "0"; test with defined() at - line 4.
706 ########
707 # op.c
708 use warnings 'misc' ;
709 opendir FH, "." ;
710 $x = 1 if $x = readdir FH ;
711 no warnings 'misc' ;
712 $x = 1 if $x = readdir FH ;
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 $x = 1 if $x = <*> ;
720 no warnings 'misc' ;
721 $x = 1 if $x = <*> ;
722 EXPECT
723 Value of glob construct can be "0"; test with defined() at - line 3.
724 ########
725 # op.c
726 use warnings 'misc' ;
727 %a = (1,2,3,4) ;
728 $x = 1 if $x = each %a ;
729 no warnings 'misc' ;
730 $x = 1 if $x = each %a ;
731 EXPECT
732 Value of each() operator can be "0"; test with defined() at - line 4.
733 ########
734 # op.c
735 use warnings 'misc' ;
736 $x = 1 while $x = <*> and 0 ;
737 no warnings 'misc' ;
738 $x = 1 while $x = <*> and 0 ;
739 EXPECT
740 Value of glob construct can be "0"; test with defined() at - line 3.
741 ########
742 # op.c
743 use warnings 'misc' ;
744 opendir FH, "." ;
745 $x = 1 while $x = readdir FH and 0 ;
746 no warnings 'misc' ;
747 $x = 1 while $x = readdir FH and 0 ;
748 closedir FH ;
749 EXPECT
750 Value of readdir() operator can be "0"; test with defined() at - line 4.
751 ########
752 # op.c
753 use warnings 'redefine' ;
754 sub fred {}
755 sub fred {}
756 no warnings 'redefine' ;
757 sub fred {}
758 EXPECT
759 Subroutine fred redefined at - line 4.
760 ########
761 # op.c
762 use warnings 'redefine' ;
763 sub fred () { 1 }
764 sub fred () { 1 }
765 no warnings 'redefine' ;
766 sub fred () { 1 }
767 EXPECT
768 Constant subroutine fred redefined at - line 4.
769 ########
770 # op.c
771 no warnings 'redefine' ;
772 sub fred () { 1 }
773 sub fred () { 2 }
774 EXPECT
775 Constant subroutine fred redefined at - line 4.
776 ########
777 # op.c
778 no warnings 'redefine' ;
779 sub fred () { 1 }
780 *fred = sub () { 2 };
781 EXPECT
782 Constant subroutine main::fred redefined at - line 4.
783 ########
784 # op.c
785 use warnings 'redefine' ;
786 format FRED =
787 .
788 format FRED =
789 .
790 no warnings 'redefine' ;
791 format FRED =
792 .
793 EXPECT
794 Format FRED redefined at - line 5.
795 ########
796 # op.c
797 use warnings 'deprecated' ;
798 push FRED;
799 no warnings 'deprecated' ;
800 push FRED;
801 EXPECT
802 Array @FRED missing the @ in argument 1 of push() at - line 3.
803 ########
804 # op.c
805 use warnings 'deprecated' ;
806 @a = keys FRED ;
807 no warnings 'deprecated' ;
808 @a = keys FRED ;
809 EXPECT
810 Hash %FRED missing the % in argument 1 of keys() at - line 3.
811 ########
812 # op.c
813 BEGIN {
814     if ($^O eq 'MacOS') {
815         print <<EOM;
816 SKIPPED
817 # no exec on Mac OS
818 EOM
819         exit;
820     }
821 }
822 use warnings 'syntax' ;
823 exec "$^X -e 1" ; 
824 my $a
825 EXPECT
826 Statement unlikely to be reached at - line 13.
827         (Maybe you meant system() when you said exec()?)
828 ########
829 # op.c
830 use warnings 'deprecated' ;
831 my @a; defined(@a);
832 EXPECT
833 defined(@array) is deprecated at - line 3.
834         (Maybe you should just omit the defined()?)
835 ########
836 # op.c
837 use warnings 'deprecated' ;
838 defined(@a = (1,2,3));
839 EXPECT
840 defined(@array) is deprecated at - line 3.
841         (Maybe you should just omit the defined()?)
842 ########
843 # op.c
844 use warnings 'deprecated' ;
845 my %h; defined(%h);
846 EXPECT
847 defined(%hash) is deprecated at - line 3.
848         (Maybe you should just omit the defined()?)
849 ########
850 # op.c
851 BEGIN {
852     if ($^O eq 'MacOS') {
853         print <<EOM;
854 SKIPPED
855 # no exec on Mac OS
856 EOM
857         exit;
858     }
859 }
860 no warnings 'syntax' ;
861 exec "$^X -e 1" ; 
862 my $a
863 EXPECT
864
865 ########
866 # op.c
867 sub fred();
868 sub fred($) {}
869 EXPECT
870 Prototype mismatch: sub main::fred () vs ($) at - line 3.
871 ########
872 # op.c
873 $^W = 0 ;
874 sub fred() ;
875 sub fred($) {}
876 {
877     no warnings 'prototype' ;
878     sub Fred() ;
879     sub Fred($) {}
880     use warnings 'prototype' ;
881     sub freD() ;
882     sub freD($) {}
883 }
884 sub FRED() ;
885 sub FRED($) {}
886 EXPECT
887 Prototype mismatch: sub main::fred () vs ($) at - line 4.
888 Prototype mismatch: sub main::freD () vs ($) at - line 11.
889 Prototype mismatch: sub main::FRED () vs ($) at - line 14.
890 ########
891 # op.c
892 use warnings 'syntax' ;
893 join /---/, 'x', 'y', 'z';
894 EXPECT
895 /---/ should probably be written as "---" at - line 3.
896 ########
897 # op.c [Perl_peep]
898 use warnings 'prototype' ;
899 fred() ; 
900 sub fred ($$) {}
901 no warnings 'prototype' ;
902 joe() ; 
903 sub joe ($$) {}
904 EXPECT
905 main::fred() called too early to check prototype at - line 3.
906 ########
907 # op.c [Perl_newATTRSUB]
908 --FILE-- abc.pm
909 use warnings 'void' ;
910 BEGIN { $| = 1; print "in begin\n"; }
911 CHECK { print "in check\n"; }
912 INIT { print "in init\n"; }
913 END { print "in end\n"; }
914 print "in mainline\n";
915 1;
916 --FILE--
917 use abc;
918 delete $INC{"abc.pm"};
919 require abc;
920 do "abc.pm";
921 EXPECT
922 in begin
923 in mainline
924 in check
925 in init
926 in begin
927 Too late to run CHECK block at abc.pm line 3.
928 Too late to run INIT block at abc.pm line 4.
929 in mainline
930 in begin
931 Too late to run CHECK block at abc.pm line 3.
932 Too late to run INIT block at abc.pm line 4.
933 in mainline
934 in end
935 in end
936 in end
937 ########
938 # op.c [Perl_newATTRSUB]
939 --FILE-- abc.pm
940 no warnings 'void' ;
941 BEGIN { $| = 1; print "in begin\n"; }
942 CHECK { print "in check\n"; }
943 INIT { print "in init\n"; }
944 END { print "in end\n"; }
945 print "in mainline\n";
946 1;
947 --FILE--
948 require abc;
949 do "abc.pm";
950 EXPECT
951 in begin
952 in mainline
953 in begin
954 in mainline
955 in end
956 in end
957 ########
958 # op.c
959 my @x;
960 use warnings 'syntax' ;
961 push(@x);
962 unshift(@x);
963 no warnings 'syntax' ;
964 push(@x);
965 unshift(@x);
966 EXPECT
967 Useless use of push with no values at - line 4.
968 Useless use of unshift with no values at - line 5.
969 ########
970 # op.c
971 # 20020401 mjd@plover.com at suggestion of jfriedl@yahoo.com
972 use warnings 'regexp';
973 split /blah/g, "blah";
974 no warnings 'regexp';
975 split /blah/g, "blah";
976 EXPECT
977 Use of /g modifier is meaningless in split at - line 4.
978 ########
979 # op.c
980 use warnings 'precedence';
981 $a = $b & $c == $d;
982 $a = $b ^ $c != $d;
983 $a = $b | $c > $d;
984 $a = $b < $c & $d;
985 $a = $b >= $c ^ $d;
986 $a = $b <= $c | $d;
987 $a = $b <=> $c & $d;
988 no warnings 'precedence';
989 $a = $b & $c == $d;
990 $a = $b ^ $c != $d;
991 $a = $b | $c > $d;
992 $a = $b < $c & $d;
993 $a = $b >= $c ^ $d;
994 $a = $b <= $c | $d;
995 $a = $b <=> $c & $d;
996 EXPECT
997 Possible precedence problem on bitwise & operator at - line 3.
998 Possible precedence problem on bitwise ^ operator at - line 4.
999 Possible precedence problem on bitwise | operator at - line 5.
1000 Possible precedence problem on bitwise & operator at - line 6.
1001 Possible precedence problem on bitwise ^ operator at - line 7.
1002 Possible precedence problem on bitwise | operator at - line 8.
1003 Possible precedence problem on bitwise & operator at - line 9.
1004 ########
1005 # op.c
1006 use integer;
1007 use warnings 'precedence';
1008 $a = $b & $c == $d;
1009 $a = $b ^ $c != $d;
1010 $a = $b | $c > $d;
1011 $a = $b < $c & $d;
1012 $a = $b >= $c ^ $d;
1013 $a = $b <= $c | $d;
1014 $a = $b <=> $c & $d;
1015 no warnings 'precedence';
1016 $a = $b & $c == $d;
1017 $a = $b ^ $c != $d;
1018 $a = $b | $c > $d;
1019 $a = $b < $c & $d;
1020 $a = $b >= $c ^ $d;
1021 $a = $b <= $c | $d;
1022 $a = $b <=> $c & $d;
1023 EXPECT
1024 Possible precedence problem on bitwise & operator at - line 4.
1025 Possible precedence problem on bitwise ^ operator at - line 5.
1026 Possible precedence problem on bitwise | operator at - line 6.
1027 Possible precedence problem on bitwise & operator at - line 7.
1028 Possible precedence problem on bitwise ^ operator at - line 8.
1029 Possible precedence problem on bitwise | operator at - line 9.
1030 Possible precedence problem on bitwise & operator at - line 10.