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