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