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