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