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