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