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