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