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