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