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