The #14949 removed this error from non-Win32.
[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      Use of "package" with no arguments is deprecated
110         package;
111
112     Package `%s' not found (did you use the incorrect case?)
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 use warnings 'void' ; close STDIN ;
339 my $x = sort (2,1,3);
340 no warnings 'void' ;
341 $x = sort (2,1,3);
342 EXPECT
343 Useless use of sort in scalar context at - line 3.
344 ########
345 # op.c
346 no warnings 'void' ; close STDIN ;
347 1 x 3 ;                 # OP_REPEAT
348                         # OP_GVSV
349 wantarray ;             # OP_WANTARRAY
350                         # OP_GV
351                         # OP_PADSV
352                         # OP_PADAV
353                         # OP_PADHV
354                         # OP_PADANY
355                         # OP_AV2ARYLEN
356 ref ;                   # OP_REF
357 \@a ;                   # OP_REFGEN
358 \$a ;                   # OP_SREFGEN
359 defined $a ;            # OP_DEFINED
360 hex $a ;                # OP_HEX
361 oct $a ;                # OP_OCT
362 length $a ;             # OP_LENGTH
363 substr $a,1 ;           # OP_SUBSTR
364 vec $a,1,2 ;            # OP_VEC
365 index $a,1,2 ;          # OP_INDEX
366 rindex $a,1,2 ;         # OP_RINDEX
367 sprintf $a ;            # OP_SPRINTF
368 $a[0] ;                 # OP_AELEM
369                         # OP_AELEMFAST
370 @a[0] ;                 # OP_ASLICE
371 #values %a ;            # OP_VALUES
372 #keys %a ;              # OP_KEYS
373 $a{0} ;                 # OP_HELEM
374 @a{0} ;                 # OP_HSLICE
375 unpack "a", "a" ;       # OP_UNPACK
376 pack $a,"" ;            # OP_PACK
377 join "" ;               # OP_JOIN
378 (@a)[0,1] ;             # OP_LSLICE
379                         # OP_ANONLIST
380                         # OP_ANONHASH
381 sort(1,2) ;             # OP_SORT
382 reverse(1,2) ;          # OP_REVERSE
383                         # OP_RANGE
384                         # OP_FLIP
385 (1 ..2) ;               # OP_FLOP
386 caller ;                # OP_CALLER
387 fileno STDIN ;          # OP_FILENO
388 eof STDIN ;             # OP_EOF
389 tell STDIN ;            # OP_TELL
390 readlink 1;             # OP_READLINK
391 time ;                  # OP_TIME
392 localtime ;             # OP_LOCALTIME
393 gmtime ;                # OP_GMTIME
394 eval { getgrnam 1 };    # OP_GGRNAM
395 eval { getgrgid 1 };    # OP_GGRGID
396 eval { getpwnam 1 };    # OP_GPWNAM
397 eval { getpwuid 1 };    # OP_GPWUID
398 EXPECT
399 ########
400 # op.c
401 use warnings 'void' ;
402 for (@{[0]}) { "$_" }           # check warning isn't duplicated
403 no warnings 'void' ;
404 for (@{[0]}) { "$_" }           # check warning isn't duplicated
405 EXPECT
406 Useless use of string in void context at - line 3.
407 ########
408 # op.c
409 use warnings 'void' ;
410 use Config ;
411 BEGIN {
412     if ( ! $Config{d_telldir}) {
413         print <<EOM ;
414 SKIPPED
415 # telldir not present
416 EOM
417         exit 
418     }
419 }
420 telldir 1 ;             # OP_TELLDIR
421 no warnings 'void' ;
422 telldir 1 ;             # OP_TELLDIR
423 EXPECT
424 Useless use of telldir in void context at - line 13.
425 ########
426 # op.c
427 use warnings 'void' ;
428 use Config ;
429 BEGIN {
430     if ( ! $Config{d_getppid}) {
431         print <<EOM ;
432 SKIPPED
433 # getppid not present
434 EOM
435         exit 
436     }
437 }
438 getppid ;               # OP_GETPPID
439 no warnings 'void' ;
440 getppid ;               # OP_GETPPID
441 EXPECT
442 Useless use of getppid in void context at - line 13.
443 ########
444 # op.c
445 use warnings 'void' ;
446 use Config ;
447 BEGIN {
448     if ( ! $Config{d_getpgrp}) {
449         print <<EOM ;
450 SKIPPED
451 # getpgrp not present
452 EOM
453         exit 
454     }
455 }
456 getpgrp ;               # OP_GETPGRP
457 no warnings 'void' ;
458 getpgrp ;               # OP_GETPGRP
459 EXPECT
460 Useless use of getpgrp in void context at - line 13.
461 ########
462 # op.c
463 use warnings 'void' ;
464 use Config ;
465 BEGIN {
466     if ( ! $Config{d_times}) {
467         print <<EOM ;
468 SKIPPED
469 # times not present
470 EOM
471         exit 
472     }
473 }
474 times ;                 # OP_TMS
475 no warnings 'void' ;
476 times ;                 # OP_TMS
477 EXPECT
478 Useless use of times in void context at - line 13.
479 ########
480 # op.c
481 use warnings 'void' ;
482 use Config ;
483 BEGIN {
484     if ( ! $Config{d_getprior} or $^O eq 'os2') { # Locks before fixpak22
485         print <<EOM ;
486 SKIPPED
487 # getpriority not present
488 EOM
489         exit 
490     }
491 }
492 getpriority 1,2;        # OP_GETPRIORITY
493 no warnings 'void' ;
494 getpriority 1,2;        # OP_GETPRIORITY
495 EXPECT
496 Useless use of getpriority in void context at - line 13.
497 ########
498 # op.c
499 use warnings 'void' ;
500 use Config ;
501 BEGIN {
502     if ( ! $Config{d_getlogin}) {
503         print <<EOM ;
504 SKIPPED
505 # getlogin not present
506 EOM
507         exit 
508     }
509 }
510 getlogin ;                      # OP_GETLOGIN
511 no warnings 'void' ;
512 getlogin ;                      # OP_GETLOGIN
513 EXPECT
514 Useless use of getlogin in void context at - line 13.
515 ########
516 # op.c
517 use warnings 'void' ;
518 use Config ; BEGIN {
519 if ( ! $Config{d_socket}) {
520     print <<EOM ;
521 SKIPPED
522 # getsockname not present
523 # getpeername not present
524 # gethostbyname not present
525 # gethostbyaddr not present
526 # gethostent not present
527 # getnetbyname not present
528 # getnetbyaddr not present
529 # getnetent not present
530 # getprotobyname not present
531 # getprotobynumber not present
532 # getprotoent not present
533 # getservbyname not present
534 # getservbyport not present
535 # getservent not present
536 EOM
537     exit 
538 } }
539 getsockname STDIN ;     # OP_GETSOCKNAME
540 getpeername STDIN ;     # OP_GETPEERNAME
541 gethostbyname 1 ;       # OP_GHBYNAME
542 gethostbyaddr 1,2;      # OP_GHBYADDR
543 gethostent ;            # OP_GHOSTENT
544 getnetbyname 1 ;        # OP_GNBYNAME
545 getnetbyaddr 1,2 ;      # OP_GNBYADDR
546 getnetent ;             # OP_GNETENT
547 getprotobyname 1;       # OP_GPBYNAME
548 getprotobynumber 1;     # OP_GPBYNUMBER
549 getprotoent ;           # OP_GPROTOENT
550 getservbyname 1,2;      # OP_GSBYNAME
551 getservbyport 1,2;      # OP_GSBYPORT
552 getservent ;            # OP_GSERVENT
553
554 no warnings 'void' ;
555 getsockname STDIN ;     # OP_GETSOCKNAME
556 getpeername STDIN ;     # OP_GETPEERNAME
557 gethostbyname 1 ;       # OP_GHBYNAME
558 gethostbyaddr 1,2;      # OP_GHBYADDR
559 gethostent ;            # OP_GHOSTENT
560 getnetbyname 1 ;        # OP_GNBYNAME
561 getnetbyaddr 1,2 ;      # OP_GNBYADDR
562 getnetent ;             # OP_GNETENT
563 getprotobyname 1;       # OP_GPBYNAME
564 getprotobynumber 1;     # OP_GPBYNUMBER
565 getprotoent ;           # OP_GPROTOENT
566 getservbyname 1,2;      # OP_GSBYNAME
567 getservbyport 1,2;      # OP_GSBYPORT
568 getservent ;            # OP_GSERVENT
569 INIT {
570    # some functions may not be there, so we exit without running
571    exit;
572 }
573 EXPECT
574 Useless use of getsockname in void context at - line 24.
575 Useless use of getpeername in void context at - line 25.
576 Useless use of gethostbyname in void context at - line 26.
577 Useless use of gethostbyaddr in void context at - line 27.
578 Useless use of gethostent in void context at - line 28.
579 Useless use of getnetbyname in void context at - line 29.
580 Useless use of getnetbyaddr in void context at - line 30.
581 Useless use of getnetent in void context at - line 31.
582 Useless use of getprotobyname in void context at - line 32.
583 Useless use of getprotobynumber in void context at - line 33.
584 Useless use of getprotoent in void context at - line 34.
585 Useless use of getservbyname in void context at - line 35.
586 Useless use of getservbyport in void context at - line 36.
587 Useless use of getservent in void context at - line 37.
588 ########
589 # op.c
590 use warnings 'void' ;
591 *a ; # OP_RV2GV
592 $a ; # OP_RV2SV
593 @a ; # OP_RV2AV
594 %a ; # OP_RV2HV
595 no warnings 'void' ;
596 *a ; # OP_RV2GV
597 $a ; # OP_RV2SV
598 @a ; # OP_RV2AV
599 %a ; # OP_RV2HV
600 EXPECT
601 Useless use of a variable in void context at - line 3.
602 Useless use of a variable in void context at - line 4.
603 Useless use of a variable in void context at - line 5.
604 Useless use of a variable in void context at - line 6.
605 ########
606 # op.c
607 use warnings 'void' ;
608 "abc"; # OP_CONST
609 7 ; # OP_CONST
610 no warnings 'void' ;
611 "abc"; # OP_CONST
612 7 ; # OP_CONST
613 EXPECT
614 Useless use of a constant in void context at - line 3.
615 Useless use of a constant in void context at - line 4.
616 ########
617 # op.c
618 #
619 use warnings 'misc' ;
620 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
621 @a =~ /abc/ ;
622 @a =~ s/a/b/ ;
623 @a =~ tr/a/b/ ;
624 @$b =~ /abc/ ;
625 @$b =~ s/a/b/ ;
626 @$b =~ tr/a/b/ ;
627 %a =~ /abc/ ;
628 %a =~ s/a/b/ ;
629 %a =~ tr/a/b/ ;
630 %$c =~ /abc/ ;
631 %$c =~ s/a/b/ ;
632 %$c =~ tr/a/b/ ;
633 {
634 no warnings 'misc' ;
635 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
636 @a =~ /abc/ ;
637 @a =~ s/a/b/ ;
638 @a =~ tr/a/b/ ;
639 @$b =~ /abc/ ;
640 @$b =~ s/a/b/ ;
641 @$b =~ tr/a/b/ ;
642 %a =~ /abc/ ;
643 %a =~ s/a/b/ ;
644 %a =~ tr/a/b/ ;
645 %$c =~ /abc/ ;
646 %$c =~ s/a/b/ ;
647 %$c =~ tr/a/b/ ;
648 }
649 EXPECT
650 Applying pattern match (m//) to @array will act on scalar(@array) at - line 5.
651 Applying substitution (s///) to @array will act on scalar(@array) at - line 6.
652 Applying transliteration (tr///) to @array will act on scalar(@array) at - line 7.
653 Applying pattern match (m//) to @array will act on scalar(@array) at - line 8.
654 Applying substitution (s///) to @array will act on scalar(@array) at - line 9.
655 Applying transliteration (tr///) to @array will act on scalar(@array) at - line 10.
656 Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 11.
657 Applying substitution (s///) to %hash will act on scalar(%hash) at - line 12.
658 Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 13.
659 Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 14.
660 Applying substitution (s///) to %hash will act on scalar(%hash) at - line 15.
661 Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 16.
662 Can't modify private array in substitution (s///) at - line 6, near "s/a/b/ ;"
663 BEGIN not safe after errors--compilation aborted at - line 18.
664 ########
665 # op.c
666 use warnings 'syntax' ;
667 my $a, $b = (1,2);
668 no warnings 'syntax' ;
669 my $c, $d = (1,2);
670 EXPECT
671 Parentheses missing around "my" list at - line 3.
672 ########
673 # op.c
674 use warnings 'syntax' ;
675 local $a, $b = (1,2);
676 no warnings 'syntax' ;
677 local $c, $d = (1,2);
678 EXPECT
679 Parentheses missing around "local" list at - line 3.
680 ########
681 # op.c
682 use warnings 'bareword' ;
683 print (ABC || 1) ;
684 no warnings 'bareword' ;
685 print (ABC || 1) ;
686 EXPECT
687 Bareword found in conditional at - line 3.
688 ########
689 --FILE-- abc
690
691 --FILE--
692 # op.c
693 use warnings 'misc' ;
694 open FH, "<abc" ;
695 $x = 1 if $x = <FH> ;
696 no warnings 'misc' ;
697 $x = 1 if $x = <FH> ;
698 EXPECT
699 Value of <HANDLE> construct can be "0"; test with defined() at - line 4.
700 ########
701 # op.c
702 use warnings 'misc' ;
703 opendir FH, "." ;
704 $x = 1 if $x = readdir FH ;
705 no warnings 'misc' ;
706 $x = 1 if $x = readdir FH ;
707 closedir FH ;
708 EXPECT
709 Value of readdir() operator can be "0"; test with defined() at - line 4.
710 ########
711 # op.c
712 use warnings 'misc' ;
713 $x = 1 if $x = <*> ;
714 no warnings 'misc' ;
715 $x = 1 if $x = <*> ;
716 EXPECT
717 Value of glob construct can be "0"; test with defined() at - line 3.
718 ########
719 # op.c
720 use warnings 'misc' ;
721 %a = (1,2,3,4) ;
722 $x = 1 if $x = each %a ;
723 no warnings 'misc' ;
724 $x = 1 if $x = each %a ;
725 EXPECT
726 Value of each() operator can be "0"; test with defined() at - line 4.
727 ########
728 # op.c
729 use warnings 'misc' ;
730 $x = 1 while $x = <*> and 0 ;
731 no warnings 'misc' ;
732 $x = 1 while $x = <*> and 0 ;
733 EXPECT
734 Value of glob construct can be "0"; test with defined() at - line 3.
735 ########
736 # op.c
737 use warnings 'misc' ;
738 opendir FH, "." ;
739 $x = 1 while $x = readdir FH and 0 ;
740 no warnings 'misc' ;
741 $x = 1 while $x = readdir FH and 0 ;
742 closedir FH ;
743 EXPECT
744 Value of readdir() operator can be "0"; test with defined() at - line 4.
745 ########
746 # op.c
747 use warnings 'redefine' ;
748 sub fred {}
749 sub fred {}
750 no warnings 'redefine' ;
751 sub fred {}
752 EXPECT
753 Subroutine fred redefined at - line 4.
754 ########
755 # op.c
756 use warnings 'redefine' ;
757 sub fred () { 1 }
758 sub fred () { 1 }
759 no warnings 'redefine' ;
760 sub fred () { 1 }
761 EXPECT
762 Constant subroutine fred redefined at - line 4.
763 ########
764 # op.c
765 no warnings 'redefine' ;
766 sub fred () { 1 }
767 sub fred () { 2 }
768 EXPECT
769 Constant subroutine fred redefined at - line 4.
770 ########
771 # op.c
772 no warnings 'redefine' ;
773 sub fred () { 1 }
774 *fred = sub () { 2 };
775 EXPECT
776 Constant subroutine fred redefined at - line 4.
777 ########
778 # op.c
779 use warnings 'redefine' ;
780 format FRED =
781 .
782 format FRED =
783 .
784 no warnings 'redefine' ;
785 format FRED =
786 .
787 EXPECT
788 Format FRED redefined at - line 5.
789 ########
790 # op.c
791 use warnings 'deprecated' ;
792 push FRED;
793 no warnings 'deprecated' ;
794 push FRED;
795 EXPECT
796 Array @FRED missing the @ in argument 1 of push() at - line 3.
797 ########
798 # op.c
799 use warnings 'deprecated' ;
800 @a = keys FRED ;
801 no warnings 'deprecated' ;
802 @a = keys FRED ;
803 EXPECT
804 Hash %FRED missing the % in argument 1 of keys() at - line 3.
805 ########
806 # op.c
807 use warnings 'syntax' ;
808 exec "$^X -e 1" ; 
809 my $a
810 EXPECT
811 Statement unlikely to be reached at - line 4.
812         (Maybe you meant system() when you said exec()?)
813 ########
814 # op.c
815 use warnings 'deprecated' ;
816 my @a; defined(@a);
817 EXPECT
818 defined(@array) is deprecated at - line 3.
819         (Maybe you should just omit the defined()?)
820 ########
821 # op.c
822 use warnings 'deprecated' ;
823 defined(@a = (1,2,3));
824 EXPECT
825 defined(@array) is deprecated at - line 3.
826         (Maybe you should just omit the defined()?)
827 ########
828 # op.c
829 use warnings 'deprecated' ;
830 my %h; defined(%h);
831 EXPECT
832 defined(%hash) is deprecated at - line 3.
833         (Maybe you should just omit the defined()?)
834 ########
835 # op.c
836 no warnings 'syntax' ;
837 exec "$^X -e 1" ; 
838 my $a
839 EXPECT
840
841 ########
842 # op.c
843 sub fred();
844 sub fred($) {}
845 EXPECT
846 Prototype mismatch: sub main::fred () vs ($) at - line 3.
847 ########
848 # op.c
849 $^W = 0 ;
850 sub fred() ;
851 sub fred($) {}
852 {
853     no warnings 'prototype' ;
854     sub Fred() ;
855     sub Fred($) {}
856     use warnings 'prototype' ;
857     sub freD() ;
858     sub freD($) {}
859 }
860 sub FRED() ;
861 sub FRED($) {}
862 EXPECT
863 Prototype mismatch: sub main::fred () vs ($) at - line 4.
864 Prototype mismatch: sub main::freD () vs ($) at - line 11.
865 Prototype mismatch: sub main::FRED () vs ($) at - line 14.
866 ########
867 # op.c
868 use warnings 'syntax' ;
869 join /---/, 'x', 'y', 'z';
870 EXPECT
871 /---/ should probably be written as "---" at - line 3.
872 ########
873 # op.c [Perl_peep]
874 use warnings 'prototype' ;
875 fred() ; 
876 sub fred ($$) {}
877 no warnings 'prototype' ;
878 joe() ; 
879 sub joe ($$) {}
880 EXPECT
881 main::fred() called too early to check prototype at - line 3.
882 ########
883 # op.c [Perl_newATTRSUB]
884 --FILE-- abc.pm
885 use warnings 'void' ;
886 BEGIN { $| = 1; print "in begin\n"; }
887 CHECK { print "in check\n"; }
888 INIT { print "in init\n"; }
889 END { print "in end\n"; }
890 print "in mainline\n";
891 1;
892 --FILE--
893 use abc;
894 delete $INC{"abc.pm"};
895 require abc;
896 do "abc.pm";
897 EXPECT
898 in begin
899 in mainline
900 in check
901 in init
902 in begin
903 Too late to run CHECK block at abc.pm line 3.
904 Too late to run INIT block at abc.pm line 4.
905 in mainline
906 in begin
907 Too late to run CHECK block at abc.pm line 3.
908 Too late to run INIT block at abc.pm line 4.
909 in mainline
910 in end
911 in end
912 in end
913 ########
914 # op.c [Perl_newATTRSUB]
915 --FILE-- abc.pm
916 no warnings 'void' ;
917 BEGIN { $| = 1; print "in begin\n"; }
918 CHECK { print "in check\n"; }
919 INIT { print "in init\n"; }
920 END { print "in end\n"; }
921 print "in mainline\n";
922 1;
923 --FILE--
924 require abc;
925 do "abc.pm";
926 EXPECT
927 in begin
928 in mainline
929 in begin
930 in mainline
931 in end
932 in end
933 ########
934 # op.c
935 my @x;
936 use warnings 'syntax' ;
937 push(@x);
938 unshift(@x);
939 no warnings 'syntax' ;
940 push(@x);
941 unshift(@x);
942 EXPECT
943 Useless use of push with no values at - line 4.
944 Useless use of unshift with no values at - line 5.
945 ########
946 # op.c
947 use warnings 'deprecated' ;
948 package;
949 no warnings 'deprecated' ;
950 package;
951 EXPECT
952 Use of "package" with no arguments is deprecated at - line 3.
953 Global symbol "BEGIN" requires explicit package name at - line 4.
954 BEGIN not safe after errors--compilation aborted at - line 4.