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