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