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