This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Disallow omitting % and @ on hash and array names
[perl5.git] / t / lib / warnings / op
CommitLineData
599cee73
PM
1 op.c AOK
2
4055dbce
RS
3 Use of my $_ is experimental
4 my $_ ;
5
599cee73
PM
6 Found = in conditional, should be ==
7 1 if $a = 1 ;
8
b80ba9b6
FC
9 Scalar value %.*s better written as $%.*s"
10 @a[3] = 2;
11 @a{3} = 2;
12
599cee73
PM
13 Useless use of time in void context
14 Useless use of a variable in void context
15 Useless use of a constant in void context
16 time ;
17 $a ;
18 "abc"
19
a801c63c
RGS
20 Useless use of sort in scalar context
21 my $x = sort (2,1,3);
22
599cee73
PM
23 Applying %s to %s will act on scalar(%s)
24 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
25 @a =~ /abc/ ;
26 @a =~ s/a/b/ ;
27 @a =~ tr/a/b/ ;
28 @$b =~ /abc/ ;
29 @$b =~ s/a/b/ ;
30 @$b =~ tr/a/b/ ;
31 %a =~ /abc/ ;
32 %a =~ s/a/b/ ;
33 %a =~ tr/a/b/ ;
34 %$c =~ /abc/ ;
35 %$c =~ s/a/b/ ;
36 %$c =~ tr/a/b/ ;
37
38
df5b6949 39 Parentheses missing around "my" list at -e line 1.
599cee73
PM
40 my $a, $b = (1,2);
41
df5b6949 42 Parentheses missing around "local" list at -e line 1.
599cee73
PM
43 local $a, $b = (1,2);
44
34d09196 45 Bareword found in conditional at -e line 1.
e476b1b5 46 use warnings 'bareword'; my $x = print(ABC || 1);
599cee73
PM
47
48 Value of %s may be \"0\"; use \"defined\"
49 $x = 1 if $x = <FH> ;
50 $x = 1 while $x = <FH> ;
51
52 Subroutine fred redefined at -e line 1.
53 sub fred{1;} sub fred{1;}
54
55 Constant subroutine %s redefined
56 sub fred() {1;} sub fred() {1;}
57
58 Format FRED redefined at /tmp/x line 5.
59 format FRED =
60 .
61 format FRED =
62 .
63
0953b66b
FC
64 push on reference is experimental [ck_fun]
65 pop on reference is experimental
66 shift on reference is experimental
67 unshift on reference is experimental
68 splice on reference is experimental
69
599cee73 70 Statement unlikely to be reached
cc507455 71 (Maybe you meant system() when you said exec()?
599cee73
PM
72 exec "true" ; my $a
73
f10b0346 74 defined(@array) is deprecated
cc507455 75 (Maybe you should just omit the defined()?)
69794302
MJD
76 my @a ; defined @a ;
77 defined (@a = (1,2,3)) ;
78
f10b0346 79 defined(%hash) is deprecated
cc507455 80 (Maybe you should just omit the defined()?)
69794302 81 my %h ; defined %h ;
89474f50 82
271c8bde
FC
83 "my %s" used in sort comparison
84
89474f50 85 $[ used in comparison (did you mean $] ?)
e508c8a4 86
0953b66b
FC
87 each on reference is experimental [ck_each]
88 keys on reference is experimental
89 values on reference is experimental
90
e508c8a4
MH
91 length() used on @array (did you mean "scalar(@array)"?)
92 length() used on %hash (did you mean "scalar(keys %hash)"?)
93
eb6e2d6f
GS
94 /---/ should probably be written as "---"
95 join(/---/, @foo);
599cee73 96
767a6a26
PM
97 %s() called too early to check prototype [Perl_peep]
98 fred() ; sub fred ($$) {}
99
100
15a8c21e 101 Package '%s' not found (did you use the incorrect case?)
3b434eb1 102
f34840d8
MJD
103 Use of /g modifier is meaningless in split
104
276b2a0c
RGS
105 Possible precedence problem on bitwise %c operator [Perl_ck_bitop]
106
0453d815
PM
107 Mandatory Warnings
108 ------------------
109 Prototype mismatch: [cv_ckproto]
110 sub fred() ;
111 sub fred($) {}
112
0453d815
PM
113 oops: oopsAV [oopsAV] TODO
114 oops: oopsHV [oopsHV] TODO
115
599cee73
PM
116__END__
117# op.c
4055dbce
RS
118use warnings 'experimental::lexical_topic' ;
119my $_;
120CORE::state $_;
121no warnings 'experimental::lexical_topic' ;
122my $_;
123CORE::state $_;
124EXPECT
125Use of my $_ is experimental at - line 3.
126Use of state $_ is experimental at - line 4.
127########
128# op.c
4438c4b7 129use warnings 'syntax' ;
599cee73 1301 if $a = 1 ;
2b7cddde
NC
1311 if $a
132 = 1 ;
4438c4b7 133no warnings 'syntax' ;
0453d815 1341 if $a = 1 ;
2b7cddde
NC
1351 if $a
136 = 1 ;
599cee73
PM
137EXPECT
138Found = in conditional, should be == at - line 3.
2b7cddde 139Found = in conditional, should be == at - line 4.
599cee73
PM
140########
141# op.c
6b7c6d95
FC
142use warnings 'syntax' ;
143use constant foo => 1;
1441 if $a = foo ;
145no warnings 'syntax' ;
1461 if $a = foo ;
147EXPECT
148########
149# op.c
b80ba9b6 150use warnings 'syntax' ;
429a2555
FC
151@a[3];
152@a{3};
153@a["]"];
154@a{"]"};
155@a["}"];
156@a{"}"};
157@a{$_};
158@a{--$_};
159@a[$_];
160@a[--$_];
b80ba9b6 161no warnings 'syntax' ;
429a2555
FC
162@a[3];
163@a{3};
b80ba9b6
FC
164EXPECT
165Scalar value @a[3] better written as $a[3] at - line 3.
166Scalar value @a{3} better written as $a{3} at - line 4.
429a2555
FC
167Scalar value @a["]"] better written as $a["]"] at - line 5.
168Scalar value @a{"]"} better written as $a{"]"} at - line 6.
169Scalar value @a["}"] better written as $a["}"] at - line 7.
170Scalar value @a{"}"} better written as $a{"}"} at - line 8.
171Scalar value @a{...} better written as $a{...} at - line 9.
172Scalar value @a{...} better written as $a{...} at - line 10.
173Scalar value @a[...] better written as $a[...] at - line 11.
174Scalar value @a[...] better written as $a[...] at - line 12.
b80ba9b6
FC
175########
176# op.c
177use utf8;
178use open qw( :utf8 :std );
179use warnings 'syntax' ;
429a2555
FC
180@à[3];
181@à{3};
b80ba9b6 182no warnings 'syntax' ;
429a2555
FC
183@à[3];
184@à{3};
b80ba9b6
FC
185EXPECT
186Scalar value @à[3] better written as $à[3] at - line 5.
187Scalar value @à{3} better written as $à{3} at - line 6.
188########
189# op.c
190use utf8;
191use open qw( :utf8 :std );
192use warnings 'syntax' ;
429a2555
FC
193@ぁ[3];
194@ぁ{3};
b80ba9b6 195no warnings 'syntax' ;
429a2555
FC
196@ぁ[3];
197@ぁ{3};
b80ba9b6
FC
198EXPECT
199Scalar value @ぁ[3] better written as $ぁ[3] at - line 5.
200Scalar value @ぁ{3} better written as $ぁ{3} at - line 6.
201########
202# op.c
429a2555
FC
203# "Scalar value better written as" false positives
204# [perl #28380] and [perl #114024]
205use warnings 'syntax';
206
207# hashes
208@h{qw"a b c"} = 1..3;
209@h{qw'a b c'} = 1..3;
210@h{qw$a b c$} = 1..3;
211@h{qw-a b c-} = 1..3;
212@h{qw#a b c#} = 1..3;
213@h{ qw#a b c#} = 1..3;
214@h{ qw#a b c#} = 1..3; # tab before qw
215@h{qw "a"};
216@h{ qw "a"};
217@h{ qw "a"};
218sub foo() { qw/abc def ghi/ }
219@X{+foo} = ( 1 .. 3 );
220$_ = "abc"; @X{split ""} = ( 1 .. 3 );
221my @s = @f{"}", "a"};
222my @s = @f{"]", "a"};
223@a{$],0};
224@_{0} = /(.*)/;
225@h{m "$re"};
226@h{qx ""} if 0;
227@h{glob ""};
228@h{readline ""};
229@h{m ""};
230use constant phoo => 1..3;
231@h{+phoo}; # rv2av
429a2555
FC
232@h{sort foo};
233@h{reverse foo};
234@h{caller 0};
235@h{lstat ""};
236@h{stat ""};
237@h{readdir ""};
238@h{system ""} if 0;
239@h{+times} if 0;
240@h{localtime 0};
241@h{gmtime 0};
242@h{eval ""};
0953b66b 243{
d401967c 244 no warnings 'experimental::autoderef';
0953b66b
FC
245 @h{each $foo} if 0;
246 @h{keys $foo} if 0;
247 @h{values $foo} if 0;
248}
429a2555
FC
249
250# arrays
251@h[qw"a b c"] = 1..3;
252@h[qw'a b c'] = 1..3;
253@h[qw$a b c$] = 1..3;
254@h[qw-a b c-] = 1..3;
255@h[qw#a b c#] = 1..3;
256@h[ qw#a b c#] = 1..3;
257@h[ qw#a b c#] = 1..3; # tab before qw
258@h[qw "a"];
259@h[ qw "a"];
260@h[ qw "a"];
261sub foo() { qw/abc def ghi/ }
262@X[+foo] = ( 1 .. 3 );
263$_ = "abc"; @X[split ""] = ( 1 .. 3 );
264my @s = @f["}", "a"];
265my @s = @f["]", "a"];
266@a[$],0];
267@_[0] = /(.*)/;
268@h[m "$re"];
269@h[qx ""] if 0;
270@h[glob ""];
271@h[readline ""];
272@h[m ""];
273use constant phoo => 1..3;
274@h[+phoo]; # rv2av
429a2555
FC
275@h[sort foo];
276@h[reverse foo];
277@h[caller 0];
278@h[lstat ""];
279@h[stat ""];
280@h[readdir ""];
281@h[system ""] if 0;
282@h[+times] if 0;
283@h[localtime 0];
284@h[gmtime 0];
285@h[eval ""];
0953b66b 286{
d401967c 287 no warnings 'experimental::autoderef';
0953b66b
FC
288 @h[each $foo] if 0;
289 @h[keys $foo] if 0;
290 @h[values $foo] if 0;
291}
429a2555
FC
292EXPECT
293########
294# op.c
295# "Scalar value better written as" should not trigger for syntax errors
296use warnings 'syntax';
297@a[]
298EXPECT
299syntax error at - line 4, near "[]"
300Execution of - aborted due to compilation errors.
301########
302# op.c
a1063b2d
RH
303my (@foo, %foo);
304%main::foo->{"bar"};
305%foo->{"bar"};
306@main::foo->[23];
307@foo->[23];
308$main::foo = {}; %$main::foo->{"bar"};
309$foo = {}; %$foo->{"bar"};
310$main::foo = []; @$main::foo->[34];
311$foo = []; @$foo->[34];
312no warnings 'deprecated';
313%main::foo->{"bar"};
314%foo->{"bar"};
315@main::foo->[23];
316@foo->[23];
317$main::foo = {}; %$main::foo->{"bar"};
318$foo = {}; %$foo->{"bar"};
319$main::foo = []; @$main::foo->[34];
320$foo = []; @$foo->[34];
321EXPECT
d1d15184 322Using a hash as a reference is deprecated at - line 3.
a1063b2d 323Using a hash as a reference is deprecated at - line 4.
d1d15184 324Using an array as a reference is deprecated at - line 5.
a1063b2d 325Using an array as a reference is deprecated at - line 6.
d1d15184 326Using a hash as a reference is deprecated at - line 7.
a1063b2d 327Using a hash as a reference is deprecated at - line 8.
d1d15184 328Using an array as a reference is deprecated at - line 9.
a1063b2d 329Using an array as a reference is deprecated at - line 10.
a1063b2d
RH
330########
331# op.c
0f539b13 332use warnings 'void' ; no warnings 'experimental::smartmatch'; close STDIN ;
baed7faa
FC
333#line 2
3341 x 3 ; # OP_REPEAT (folded)
335(1) x 3 ; # OP_REPEAT
599cee73
PM
336 # OP_GVSV
337wantarray ; # OP_WANTARRAY
338 # OP_GV
339 # OP_PADSV
340 # OP_PADAV
341 # OP_PADHV
342 # OP_PADANY
343 # OP_AV2ARYLEN
344ref ; # OP_REF
345\@a ; # OP_REFGEN
346\$a ; # OP_SREFGEN
347defined $a ; # OP_DEFINED
348hex $a ; # OP_HEX
349oct $a ; # OP_OCT
350length $a ; # OP_LENGTH
351substr $a,1 ; # OP_SUBSTR
352vec $a,1,2 ; # OP_VEC
353index $a,1,2 ; # OP_INDEX
354rindex $a,1,2 ; # OP_RINDEX
355sprintf $a ; # OP_SPRINTF
356$a[0] ; # OP_AELEM
357 # OP_AELEMFAST
358@a[0] ; # OP_ASLICE
359#values %a ; # OP_VALUES
360#keys %a ; # OP_KEYS
361$a{0} ; # OP_HELEM
362@a{0} ; # OP_HSLICE
363unpack "a", "a" ; # OP_UNPACK
364pack $a,"" ; # OP_PACK
365join "" ; # OP_JOIN
366(@a)[0,1] ; # OP_LSLICE
367 # OP_ANONLIST
368 # OP_ANONHASH
369sort(1,2) ; # OP_SORT
370reverse(1,2) ; # OP_REVERSE
371 # OP_RANGE
372 # OP_FLIP
373(1 ..2) ; # OP_FLOP
374caller ; # OP_CALLER
375fileno STDIN ; # OP_FILENO
376eof STDIN ; # OP_EOF
377tell STDIN ; # OP_TELL
378readlink 1; # OP_READLINK
379time ; # OP_TIME
380localtime ; # OP_LOCALTIME
381gmtime ; # OP_GMTIME
dfe13c55
GS
382eval { getgrnam 1 }; # OP_GGRNAM
383eval { getgrgid 1 }; # OP_GGRGID
384eval { getpwnam 1 }; # OP_GPWNAM
385eval { getpwuid 1 }; # OP_GPWUID
78e1b766 386prototype "foo"; # OP_PROTOTYPE
74295f0b
MS
387$a ~~ $b; # OP_SMARTMATCH
388$a <=> $b; # OP_NCMP
60282a49
KW
389"dsatrewq";
390"diatrewq";
391"igatrewq";
703227f5
FC
392use 5.015;
393__SUB__ # OP_RUNCV
599cee73 394EXPECT
baed7faa 395Useless use of a constant ("111") in void context at - line 2.
42d38218 396Useless use of repeat (x) in void context at - line 3.
599cee73
PM
397Useless use of wantarray in void context at - line 5.
398Useless use of reference-type operator in void context at - line 12.
399Useless use of reference constructor in void context at - line 13.
d6c467eb 400Useless use of single ref constructor in void context at - line 14.
599cee73
PM
401Useless use of defined operator in void context at - line 15.
402Useless use of hex in void context at - line 16.
403Useless use of oct in void context at - line 17.
404Useless use of length in void context at - line 18.
405Useless use of substr in void context at - line 19.
406Useless use of vec in void context at - line 20.
407Useless use of index in void context at - line 21.
408Useless use of rindex in void context at - line 22.
409Useless use of sprintf in void context at - line 23.
410Useless use of array element in void context at - line 24.
411Useless use of array slice in void context at - line 26.
f1612b5c 412Useless use of hash element in void context at - line 29.
599cee73
PM
413Useless use of hash slice in void context at - line 30.
414Useless use of unpack in void context at - line 31.
415Useless use of pack in void context at - line 32.
297b36dc 416Useless use of join or string in void context at - line 33.
599cee73
PM
417Useless use of list slice in void context at - line 34.
418Useless use of sort in void context at - line 37.
419Useless use of reverse in void context at - line 38.
420Useless use of range (or flop) in void context at - line 41.
421Useless use of caller in void context at - line 42.
422Useless use of fileno in void context at - line 43.
423Useless use of eof in void context at - line 44.
424Useless use of tell in void context at - line 45.
425Useless use of readlink in void context at - line 46.
426Useless use of time in void context at - line 47.
427Useless use of localtime in void context at - line 48.
428Useless use of gmtime in void context at - line 49.
429Useless use of getgrnam in void context at - line 50.
430Useless use of getgrgid in void context at - line 51.
431Useless use of getpwnam in void context at - line 52.
432Useless use of getpwuid in void context at - line 53.
78e1b766 433Useless use of subroutine prototype in void context at - line 54.
f5df4782
RGS
434Useless use of smart match in void context at - line 55.
435Useless use of numeric comparison (<=>) in void context at - line 56.
60282a49
KW
436Useless use of a constant ("dsatrewq") in void context at - line 57.
437Useless use of a constant ("diatrewq") in void context at - line 58.
438Useless use of a constant ("igatrewq") in void context at - line 59.
439Useless use of __SUB__ in void context at - line 61.
599cee73
PM
440########
441# op.c
a801c63c
RGS
442use warnings 'void' ; close STDIN ;
443my $x = sort (2,1,3);
444no warnings 'void' ;
445$x = sort (2,1,3);
446EXPECT
447Useless use of sort in scalar context at - line 3.
448########
449# op.c
4438c4b7 450no warnings 'void' ; close STDIN ;
0453d815
PM
4511 x 3 ; # OP_REPEAT
452 # OP_GVSV
453wantarray ; # OP_WANTARRAY
454 # OP_GV
455 # OP_PADSV
456 # OP_PADAV
457 # OP_PADHV
458 # OP_PADANY
459 # OP_AV2ARYLEN
460ref ; # OP_REF
461\@a ; # OP_REFGEN
462\$a ; # OP_SREFGEN
463defined $a ; # OP_DEFINED
464hex $a ; # OP_HEX
465oct $a ; # OP_OCT
466length $a ; # OP_LENGTH
467substr $a,1 ; # OP_SUBSTR
468vec $a,1,2 ; # OP_VEC
469index $a,1,2 ; # OP_INDEX
470rindex $a,1,2 ; # OP_RINDEX
471sprintf $a ; # OP_SPRINTF
472$a[0] ; # OP_AELEM
473 # OP_AELEMFAST
474@a[0] ; # OP_ASLICE
475#values %a ; # OP_VALUES
476#keys %a ; # OP_KEYS
477$a{0} ; # OP_HELEM
478@a{0} ; # OP_HSLICE
479unpack "a", "a" ; # OP_UNPACK
480pack $a,"" ; # OP_PACK
481join "" ; # OP_JOIN
482(@a)[0,1] ; # OP_LSLICE
483 # OP_ANONLIST
484 # OP_ANONHASH
485sort(1,2) ; # OP_SORT
486reverse(1,2) ; # OP_REVERSE
487 # OP_RANGE
488 # OP_FLIP
489(1 ..2) ; # OP_FLOP
490caller ; # OP_CALLER
491fileno STDIN ; # OP_FILENO
492eof STDIN ; # OP_EOF
493tell STDIN ; # OP_TELL
494readlink 1; # OP_READLINK
495time ; # OP_TIME
496localtime ; # OP_LOCALTIME
497gmtime ; # OP_GMTIME
498eval { getgrnam 1 }; # OP_GGRNAM
499eval { getgrgid 1 }; # OP_GGRGID
500eval { getpwnam 1 }; # OP_GPWNAM
501eval { getpwuid 1 }; # OP_GPWUID
78e1b766 502prototype "foo"; # OP_PROTOTYPE
0453d815
PM
503EXPECT
504########
505# op.c
4438c4b7 506use warnings 'void' ;
68c73484 507for (@{[0]}) { "$_" } # check warning isn't duplicated
4438c4b7 508no warnings 'void' ;
0453d815 509for (@{[0]}) { "$_" } # check warning isn't duplicated
68c73484
JH
510EXPECT
511Useless use of string in void context at - line 3.
512########
513# op.c
4438c4b7 514use warnings 'void' ;
599cee73
PM
515use Config ;
516BEGIN {
517 if ( ! $Config{d_telldir}) {
518 print <<EOM ;
519SKIPPED
520# telldir not present
521EOM
522 exit
523 }
524}
525telldir 1 ; # OP_TELLDIR
4438c4b7 526no warnings 'void' ;
0453d815 527telldir 1 ; # OP_TELLDIR
599cee73
PM
528EXPECT
529Useless use of telldir in void context at - line 13.
530########
531# op.c
4438c4b7 532use warnings 'void' ;
599cee73
PM
533use Config ;
534BEGIN {
535 if ( ! $Config{d_getppid}) {
536 print <<EOM ;
537SKIPPED
538# getppid not present
539EOM
540 exit
541 }
542}
543getppid ; # OP_GETPPID
4438c4b7 544no warnings 'void' ;
0453d815 545getppid ; # OP_GETPPID
599cee73
PM
546EXPECT
547Useless use of getppid in void context at - line 13.
548########
549# op.c
4438c4b7 550use warnings 'void' ;
599cee73
PM
551use Config ;
552BEGIN {
553 if ( ! $Config{d_getpgrp}) {
554 print <<EOM ;
555SKIPPED
556# getpgrp not present
557EOM
558 exit
559 }
560}
561getpgrp ; # OP_GETPGRP
4438c4b7 562no warnings 'void' ;
0453d815 563getpgrp ; # OP_GETPGRP
599cee73
PM
564EXPECT
565Useless use of getpgrp in void context at - line 13.
566########
567# op.c
4438c4b7 568use warnings 'void' ;
599cee73
PM
569use Config ;
570BEGIN {
571 if ( ! $Config{d_times}) {
572 print <<EOM ;
573SKIPPED
574# times not present
575EOM
576 exit
577 }
578}
579times ; # OP_TMS
4438c4b7 580no warnings 'void' ;
0453d815 581times ; # OP_TMS
599cee73
PM
582EXPECT
583Useless use of times in void context at - line 13.
584########
585# op.c
4438c4b7 586use warnings 'void' ;
599cee73
PM
587use Config ;
588BEGIN {
e96326af 589 if ( ! $Config{d_getprior} or $^O eq 'os2') { # Locks before fixpak22
599cee73
PM
590 print <<EOM ;
591SKIPPED
592# getpriority not present
593EOM
594 exit
595 }
596}
597getpriority 1,2; # OP_GETPRIORITY
4438c4b7 598no warnings 'void' ;
0453d815 599getpriority 1,2; # OP_GETPRIORITY
599cee73
PM
600EXPECT
601Useless use of getpriority in void context at - line 13.
602########
603# op.c
4438c4b7 604use warnings 'void' ;
599cee73
PM
605use Config ;
606BEGIN {
607 if ( ! $Config{d_getlogin}) {
608 print <<EOM ;
609SKIPPED
610# getlogin not present
611EOM
612 exit
613 }
614}
615getlogin ; # OP_GETLOGIN
4438c4b7 616no warnings 'void' ;
0453d815 617getlogin ; # OP_GETLOGIN
599cee73
PM
618EXPECT
619Useless use of getlogin in void context at - line 13.
620########
621# op.c
4438c4b7 622use warnings 'void' ;
599cee73
PM
623use Config ; BEGIN {
624if ( ! $Config{d_socket}) {
625 print <<EOM ;
626SKIPPED
627# getsockname not present
628# getpeername not present
629# gethostbyname not present
630# gethostbyaddr not present
631# gethostent not present
632# getnetbyname not present
633# getnetbyaddr not present
634# getnetent not present
635# getprotobyname not present
636# getprotobynumber not present
637# getprotoent not present
638# getservbyname not present
639# getservbyport not present
640# getservent not present
641EOM
642 exit
643} }
644getsockname STDIN ; # OP_GETSOCKNAME
645getpeername STDIN ; # OP_GETPEERNAME
646gethostbyname 1 ; # OP_GHBYNAME
647gethostbyaddr 1,2; # OP_GHBYADDR
648gethostent ; # OP_GHOSTENT
649getnetbyname 1 ; # OP_GNBYNAME
650getnetbyaddr 1,2 ; # OP_GNBYADDR
651getnetent ; # OP_GNETENT
652getprotobyname 1; # OP_GPBYNAME
653getprotobynumber 1; # OP_GPBYNUMBER
654getprotoent ; # OP_GPROTOENT
655getservbyname 1,2; # OP_GSBYNAME
656getservbyport 1,2; # OP_GSBYPORT
657getservent ; # OP_GSERVENT
0453d815 658
4438c4b7 659no warnings 'void' ;
0453d815
PM
660getsockname STDIN ; # OP_GETSOCKNAME
661getpeername STDIN ; # OP_GETPEERNAME
662gethostbyname 1 ; # OP_GHBYNAME
663gethostbyaddr 1,2; # OP_GHBYADDR
664gethostent ; # OP_GHOSTENT
665getnetbyname 1 ; # OP_GNBYNAME
666getnetbyaddr 1,2 ; # OP_GNBYADDR
667getnetent ; # OP_GNETENT
668getprotobyname 1; # OP_GPBYNAME
669getprotobynumber 1; # OP_GPBYNUMBER
670getprotoent ; # OP_GPROTOENT
671getservbyname 1,2; # OP_GSBYNAME
672getservbyport 1,2; # OP_GSBYPORT
673getservent ; # OP_GSERVENT
dfe13c55
GS
674INIT {
675 # some functions may not be there, so we exit without running
676 exit;
677}
599cee73
PM
678EXPECT
679Useless use of getsockname in void context at - line 24.
680Useless use of getpeername in void context at - line 25.
681Useless use of gethostbyname in void context at - line 26.
682Useless use of gethostbyaddr in void context at - line 27.
683Useless use of gethostent in void context at - line 28.
684Useless use of getnetbyname in void context at - line 29.
685Useless use of getnetbyaddr in void context at - line 30.
686Useless use of getnetent in void context at - line 31.
687Useless use of getprotobyname in void context at - line 32.
688Useless use of getprotobynumber in void context at - line 33.
689Useless use of getprotoent in void context at - line 34.
690Useless use of getservbyname in void context at - line 35.
691Useless use of getservbyport in void context at - line 36.
692Useless use of getservent in void context at - line 37.
693########
694# op.c
4438c4b7 695use warnings 'void' ;
599cee73
PM
696*a ; # OP_RV2GV
697$a ; # OP_RV2SV
698@a ; # OP_RV2AV
699%a ; # OP_RV2HV
4438c4b7 700no warnings 'void' ;
0453d815
PM
701*a ; # OP_RV2GV
702$a ; # OP_RV2SV
703@a ; # OP_RV2AV
704%a ; # OP_RV2HV
599cee73
PM
705EXPECT
706Useless use of a variable in void context at - line 3.
707Useless use of a variable in void context at - line 4.
708Useless use of a variable in void context at - line 5.
709Useless use of a variable in void context at - line 6.
710########
711# op.c
4438c4b7 712use warnings 'void' ;
599cee73
PM
713"abc"; # OP_CONST
7147 ; # OP_CONST
86f9315f
RD
715"x" . "y"; # optimized to OP_CONST
7162 + 2; # optimized to OP_CONST
e7fec78e 717use constant U => undef;
fa01e093 718U;
919f76a3 719qq/" \n/;
fa01e093 7205 || print "bad\n"; # test OPpCONST_SHORTCIRCUIT
e7fec78e 721print "boo\n" if U; # test OPpCONST_SHORTCIRCUIT
1b268608 722if($foo){}elsif(""){} # test OPpCONST_SHORTCIRCUIT
4438c4b7 723no warnings 'void' ;
0453d815
PM
724"abc"; # OP_CONST
7257 ; # OP_CONST
86f9315f
RD
726"x" . "y"; # optimized to OP_CONST
7272 + 2; # optimized to OP_CONST
599cee73 728EXPECT
919f76a3 729Useless use of a constant ("abc") in void context at - line 3.
86f9315f 730Useless use of a constant (7) in void context at - line 4.
919f76a3 731Useless use of a constant ("xy") in void context at - line 5.
86f9315f 732Useless use of a constant (4) in void context at - line 6.
fa01e093 733Useless use of a constant (undef) in void context at - line 8.
919f76a3 734Useless use of a constant ("\"\t\n") in void context at - line 9.
599cee73
PM
735########
736# op.c
34ee6772
BF
737use utf8;
738use open qw( :utf8 :std );
739use warnings 'void' ;
740"àḆc"; # OP_CONST
741"Ẋ" . "ƴ"; # optimized to OP_CONST
742FOO; # Bareword optimized to OP_CONST
743use constant ů => undef;
744ů;
7455 || print "bad\n"; # test OPpCONST_SHORTCIRCUIT
746print "boo\n" if ů; # test OPpCONST_SHORTCIRCUIT
747no warnings 'void' ;
748"àḆc"; # OP_CONST
749"Ẋ" . "ƴ"; # optimized to OP_CONST
750EXPECT
919f76a3
RGS
751Useless use of a constant ("\340\x{1e06}c") in void context at - line 5.
752Useless use of a constant ("\x{1e8a}\x{1b4}") in void context at - line 6.
753Useless use of a constant ("\x{ff26}\x{ff2f}\x{ff2f}") in void context at - line 7.
34ee6772
BF
754Useless use of a constant (undef) in void context at - line 9.
755########
756# op.c
7f01dc7a 757#
e476b1b5 758use warnings 'misc' ;
b08e453b 759my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;my $d = 'test';
599cee73 760@a =~ /abc/ ;
c6771ab6
FC
761@a2 =~ s/a/b/ ;
762@a3 =~ tr/a/b/ ;
599cee73
PM
763@$b =~ /abc/ ;
764@$b =~ s/a/b/ ;
765@$b =~ tr/a/b/ ;
766%a =~ /abc/ ;
c6771ab6
FC
767%a2 =~ s/a/b/ ;
768%a3 =~ tr/a/b/ ;
599cee73
PM
769%$c =~ /abc/ ;
770%$c =~ s/a/b/ ;
771%$c =~ tr/a/b/ ;
b08e453b 772$d =~ tr/a/b/d ;
c6771ab6 773$d2 =~ tr/a/bc/;
b8c388a9 774$d3 =~ tr//b/c;
0453d815 775{
e476b1b5 776no warnings 'misc' ;
b08e453b 777my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ; my $d = 'test';
0453d815
PM
778@a =~ /abc/ ;
779@a =~ s/a/b/ ;
780@a =~ tr/a/b/ ;
781@$b =~ /abc/ ;
782@$b =~ s/a/b/ ;
783@$b =~ tr/a/b/ ;
784%a =~ /abc/ ;
785%a =~ s/a/b/ ;
786%a =~ tr/a/b/ ;
787%$c =~ /abc/ ;
788%$c =~ s/a/b/ ;
789%$c =~ tr/a/b/ ;
b08e453b 790$d =~ tr/a/b/d ;
791$d =~ tr/a/bc/ ;
b8c388a9 792$d =~ tr//b/c;
0453d815 793}
599cee73 794EXPECT
c6771ab6
FC
795Applying pattern match (m//) to @a will act on scalar(@a) at - line 5.
796Applying substitution (s///) to @a2 will act on scalar(@a2) at - line 6.
797Applying transliteration (tr///) to @a3 will act on scalar(@a3) at - line 7.
42d38218
MS
798Applying pattern match (m//) to @array will act on scalar(@array) at - line 8.
799Applying substitution (s///) to @array will act on scalar(@array) at - line 9.
f1612b5c 800Applying transliteration (tr///) to @array will act on scalar(@array) at - line 10.
c6771ab6
FC
801Applying pattern match (m//) to %a will act on scalar(%a) at - line 11.
802Applying substitution (s///) to %a2 will act on scalar(%a2) at - line 12.
803Applying transliteration (tr///) to %a3 will act on scalar(%a3) at - line 13.
42d38218
MS
804Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 14.
805Applying substitution (s///) to %hash will act on scalar(%hash) at - line 15.
f1612b5c 806Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 16.
b08e453b 807Useless use of /d modifier in transliteration operator at - line 17.
808Replacement list is longer than search list at - line 18.
c6771ab6 809Can't modify array dereference in substitution (s///) at - line 6, near "s/a/b/ ;"
b8c388a9 810BEGIN not safe after errors--compilation aborted at - line 21.
599cee73
PM
811########
812# op.c
8473848f 813use warnings 'parenthesis' ;
599cee73 814my $a, $b = (1,2);
8473848f 815my @foo,%bar, $quux; # there's a TAB here
bac662ee 816my $x, $y or print;
8473848f 817no warnings 'parenthesis' ;
0453d815 818my $c, $d = (1,2);
599cee73 819EXPECT
df5b6949 820Parentheses missing around "my" list at - line 3.
8473848f 821Parentheses missing around "my" list at - line 4.
599cee73
PM
822########
823# op.c
8473848f
RGS
824use warnings 'parenthesis' ;
825our $a, $b = (1,2);
826no warnings 'parenthesis' ;
827our $c, $d = (1,2);
828EXPECT
829Parentheses missing around "our" list at - line 3.
830########
831# op.c
832use warnings 'parenthesis' ;
599cee73 833local $a, $b = (1,2);
8473848f
RGS
834local *f, *g;
835no warnings 'parenthesis' ;
0453d815 836local $c, $d = (1,2);
599cee73 837EXPECT
df5b6949 838Parentheses missing around "local" list at - line 3.
8473848f 839Parentheses missing around "local" list at - line 4.
599cee73
PM
840########
841# op.c
e476b1b5 842use warnings 'bareword' ;
599cee73 843print (ABC || 1) ;
e476b1b5 844no warnings 'bareword' ;
0453d815 845print (ABC || 1) ;
599cee73 846EXPECT
34d09196 847Bareword found in conditional at - line 3.
599cee73
PM
848########
849--FILE-- abc
850
851--FILE--
852# op.c
e476b1b5 853use warnings 'misc' ;
599cee73
PM
854open FH, "<abc" ;
855$x = 1 if $x = <FH> ;
502e5101
NC
856$x = 1 if $x
857 = <FH> ;
e476b1b5 858no warnings 'misc' ;
0453d815 859$x = 1 if $x = <FH> ;
502e5101
NC
860$x = 1 if $x
861 = <FH> ;
599cee73
PM
862EXPECT
863Value of <HANDLE> construct can be "0"; test with defined() at - line 4.
502e5101 864Value of <HANDLE> construct can be "0"; test with defined() at - line 5.
599cee73
PM
865########
866# op.c
e476b1b5 867use warnings 'misc' ;
599cee73
PM
868opendir FH, "." ;
869$x = 1 if $x = readdir FH ;
502e5101
NC
870$x = 1 if $x
871 = readdir FH ;
e476b1b5 872no warnings 'misc' ;
0453d815 873$x = 1 if $x = readdir FH ;
502e5101
NC
874$x = 1 if $x
875 = readdir FH ;
599cee73
PM
876closedir FH ;
877EXPECT
878Value of readdir() operator can be "0"; test with defined() at - line 4.
502e5101 879Value of readdir() operator can be "0"; test with defined() at - line 5.
599cee73
PM
880########
881# op.c
e476b1b5 882use warnings 'misc' ;
599cee73 883$x = 1 if $x = <*> ;
502e5101
NC
884$x = 1 if $x
885 = <*> ;
e476b1b5 886no warnings 'misc' ;
0453d815 887$x = 1 if $x = <*> ;
502e5101
NC
888$x = 1 if $x
889 = <*> ;
599cee73
PM
890EXPECT
891Value of glob construct can be "0"; test with defined() at - line 3.
502e5101 892Value of glob construct can be "0"; test with defined() at - line 4.
599cee73
PM
893########
894# op.c
e476b1b5 895use warnings 'misc' ;
599cee73
PM
896%a = (1,2,3,4) ;
897$x = 1 if $x = each %a ;
e476b1b5 898no warnings 'misc' ;
0453d815 899$x = 1 if $x = each %a ;
599cee73
PM
900EXPECT
901Value of each() operator can be "0"; test with defined() at - line 4.
902########
903# op.c
e476b1b5 904use warnings 'misc' ;
599cee73 905$x = 1 while $x = <*> and 0 ;
e476b1b5 906no warnings 'misc' ;
0453d815 907$x = 1 while $x = <*> and 0 ;
599cee73
PM
908EXPECT
909Value of glob construct can be "0"; test with defined() at - line 3.
910########
911# op.c
e476b1b5 912use warnings 'misc' ;
599cee73
PM
913opendir FH, "." ;
914$x = 1 while $x = readdir FH and 0 ;
e476b1b5 915no warnings 'misc' ;
0453d815 916$x = 1 while $x = readdir FH and 0 ;
599cee73
PM
917closedir FH ;
918EXPECT
919Value of readdir() operator can be "0"; test with defined() at - line 4.
920########
921# op.c
59e10468
RGS
922use warnings 'misc';
923open FH, "<abc";
59e10468
RGS
924($_ = <FH>) // ($_ = 1);
925opendir DH, ".";
59e10468 926%a = (1,2,3,4) ;
59e10468
RGS
927EXPECT
928########
929# op.c
4438c4b7 930use warnings 'redefine' ;
599cee73
PM
931sub fred {}
932sub fred {}
2d4e1700
NC
933sub fred { # warning should be for this line
934}
4438c4b7 935no warnings 'redefine' ;
0453d815 936sub fred {}
2d4e1700
NC
937sub fred {
938}
599cee73
PM
939EXPECT
940Subroutine fred redefined at - line 4.
2d4e1700 941Subroutine fred redefined at - line 5.
599cee73
PM
942########
943# op.c
4438c4b7 944use warnings 'redefine' ;
599cee73
PM
945sub fred () { 1 }
946sub fred () { 1 }
4438c4b7 947no warnings 'redefine' ;
0453d815 948sub fred () { 1 }
599cee73
PM
949EXPECT
950Constant subroutine fred redefined at - line 4.
951########
952# op.c
efcf35c4
FC
953sub fred () { 1 }
954sub fred () { 2 }
955EXPECT
956Constant subroutine fred redefined at - line 3.
957########
958# op.c
959sub fred () { 1 }
960*fred = sub () { 2 };
961EXPECT
962Constant subroutine main::fred redefined at - line 3.
963########
964# op.c
ee0832ce
FC
965use feature "lexical_subs", "state";
966my sub fred () { 1 }
967sub fred { 2 };
968my sub george { 1 }
969sub george () { 2 } # should *not* produce redef warnings by default
970state sub phred () { 1 }
971sub phred { 2 };
972state sub jorge { 1 }
973sub jorge () { 2 } # should *not* produce redef warnings by default
974EXPECT
64fbf0dd 975The lexical_subs feature is experimental at - line 3.
ee0832ce
FC
976Prototype mismatch: sub fred () vs none at - line 4.
977Constant subroutine fred redefined at - line 4.
64fbf0dd 978The lexical_subs feature is experimental at - line 5.
ee0832ce 979Prototype mismatch: sub george: none vs () at - line 6.
64fbf0dd 980The lexical_subs feature is experimental at - line 7.
ee0832ce
FC
981Prototype mismatch: sub phred () vs none at - line 8.
982Constant subroutine phred redefined at - line 8.
64fbf0dd 983The lexical_subs feature is experimental at - line 9.
ee0832ce
FC
984Prototype mismatch: sub jorge: none vs () at - line 10.
985########
986# op.c
036b4402
GS
987no warnings 'redefine' ;
988sub fred () { 1 }
989sub fred () { 2 }
990EXPECT
036b4402
GS
991########
992# op.c
993no warnings 'redefine' ;
994sub fred () { 1 }
995*fred = sub () { 2 };
996EXPECT
036b4402
GS
997########
998# op.c
4438c4b7 999use warnings 'redefine' ;
599cee73
PM
1000format FRED =
1001.
1002format FRED =
1003.
4438c4b7 1004no warnings 'redefine' ;
0453d815
PM
1005format FRED =
1006.
599cee73
PM
1007EXPECT
1008Format FRED redefined at - line 5.
1009########
5b3c80aa 1010# op.c [Perl_ck_fun]
0953b66b
FC
1011$fred = [];
1012push $fred;
1013pop $fred;
1014shift $fred;
1015unshift $fred;
1016splice $fred;
d401967c 1017no warnings 'experimental::autoderef' ;
0953b66b
FC
1018push $fred;
1019pop $fred;
1020shift $fred;
1021unshift $fred;
1022splice $fred;
1023EXPECT
1024push on reference is experimental at - line 3.
1025pop on reference is experimental at - line 4.
1026shift on reference is experimental at - line 5.
1027unshift on reference is experimental at - line 6.
1028splice on reference is experimental at - line 7.
1029########
1030# op.c
573d2b1a 1031use warnings 'exec' ;
dfe13c55 1032exec "$^X -e 1" ;
599cee73
PM
1033my $a
1034EXPECT
7b903762 1035Statement unlikely to be reached at - line 4.
cc507455 1036 (Maybe you meant system() when you said exec()?)
69794302 1037########
ea31ed66 1038# op.c, no warning if exec isn't a statement.
573d2b1a 1039use warnings 'exec' ;
ea31ed66
GG
1040$a || exec "$^X -e 1" ;
1041my $a
1042EXPECT
1043########
69794302 1044# op.c
b880f709
NC
1045defined(@a);
1046EXPECT
1047defined(@array) is deprecated at - line 2.
1048 (Maybe you should just omit the defined()?)
1049########
1050# op.c
69794302
MJD
1051my @a; defined(@a);
1052EXPECT
d1d15184 1053defined(@array) is deprecated at - line 2.
cc507455 1054 (Maybe you should just omit the defined()?)
69794302
MJD
1055########
1056# op.c
69794302
MJD
1057defined(@a = (1,2,3));
1058EXPECT
d1d15184 1059defined(@array) is deprecated at - line 2.
cc507455 1060 (Maybe you should just omit the defined()?)
69794302
MJD
1061########
1062# op.c
b880f709
NC
1063defined(%h);
1064EXPECT
1065defined(%hash) is deprecated at - line 2.
1066 (Maybe you should just omit the defined()?)
1067########
1068# op.c
69794302
MJD
1069my %h; defined(%h);
1070EXPECT
d1d15184 1071defined(%hash) is deprecated at - line 2.
cc507455 1072 (Maybe you should just omit the defined()?)
0453d815
PM
1073########
1074# op.c
573d2b1a 1075no warnings 'exec' ;
0453d815
PM
1076exec "$^X -e 1" ;
1077my $a
1078EXPECT
1079
1080########
1081# op.c
1082sub fred();
1083sub fred($) {}
105ff74c
FC
1084use constant foo=>bar; sub foo(@);
1085use constant bav=>bar; sub bav(); # no warning
1086sub btu; sub btu();
0453d815
PM
1087EXPECT
1088Prototype mismatch: sub main::fred () vs ($) at - line 3.
105ff74c
FC
1089Prototype mismatch: sub foo () vs (@) at - line 4.
1090Prototype mismatch: sub btu: none vs () at - line 6.
0453d815
PM
1091########
1092# op.c
dab1c735
BF
1093use utf8;
1094use open qw( :utf8 :std );
1095sub frèd();
1096sub frèd($) {}
1097EXPECT
1098Prototype mismatch: sub main::frèd () vs ($) at - line 5.
1099########
1100# op.c
1101use utf8;
1102use open qw( :utf8 :std );
1103use warnings;
b54d603d 1104eval "sub fòò (@\$\0) {}";
dab1c735 1105EXPECT
b54d603d
PM
1106Prototype after '@' for main::fòò : @$\0 at (eval 1) line 1.
1107Illegal character in prototype for main::fòò : @$\0 at (eval 1) line 1.
dab1c735
BF
1108########
1109# op.c
1110use utf8;
1111use open qw( :utf8 :std );
1112use warnings;
b54d603d 1113eval "sub foo (@\0) {}";
dab1c735 1114EXPECT
b54d603d
PM
1115Prototype after '@' for main::foo : @\0 at (eval 1) line 1.
1116Illegal character in prototype for main::foo : @\0 at (eval 1) line 1.
dab1c735
BF
1117########
1118# op.c
1119use utf8;
1120use open qw( :utf8 :std );
1121use warnings;
b54d603d
PM
1122BEGIN { $::{"foo"} = "\@\$\0L\351on" }
1123BEGIN { eval "sub foo (@\$\0L\x{c3}\x{a9}on) {}"; }
dab1c735 1124EXPECT
b54d603d
PM
1125Prototype after '@' for main::foo : @$\x{0}L... at (eval 1) line 1.
1126Illegal character in prototype for main::foo : @$\x{0}L... at (eval 1) line 1.
dab1c735
BF
1127########
1128# op.c
1129use utf8;
1130use open qw( :utf8 :std );
1131use warnings;
b54d603d 1132BEGIN { eval "sub foo (@\0) {}"; }
dab1c735 1133EXPECT
b54d603d
PM
1134Prototype after '@' for main::foo : @\0 at (eval 1) line 1.
1135Illegal character in prototype for main::foo : @\0 at (eval 1) line 1.
97eb901d
BF
1136########
1137# op.c
1138use warnings;
b54d603d 1139eval "sub foo (@\xAB) {}";
97eb901d 1140EXPECT
b54d603d
PM
1141Prototype after '@' for main::foo : @\x{ab} at (eval 1) line 1.
1142Illegal character in prototype for main::foo : @\x{ab} at (eval 1) line 1.
97eb901d
BF
1143########
1144# op.c
1145use utf8;
1146use open qw( :utf8 :std );
1147use warnings;
b54d603d 1148BEGIN { eval "sub foo (@\x{30cb}) {}"; }
97eb901d 1149EXPECT
b54d603d
PM
1150Prototype after '@' for main::foo : @\x{30cb} at (eval 1) line 1.
1151Illegal character in prototype for main::foo : @\x{30cb} at (eval 1) line 1.
dab1c735
BF
1152########
1153# op.c
1154use utf8;
1155use open qw( :utf8 :std );
1156use warnings;
1157BEGIN { $::{"foo"} = "\x{30cb}" }
1158BEGIN { eval "sub foo {}"; }
1159EXPECT
1160Prototype mismatch: sub main::foo (ニ) vs none at (eval 1) line 1.
1161########
1162# op.c
0453d815
PM
1163$^W = 0 ;
1164sub fred() ;
1165sub fred($) {}
1166{
e476b1b5 1167 no warnings 'prototype' ;
0453d815
PM
1168 sub Fred() ;
1169 sub Fred($) {}
e476b1b5 1170 use warnings 'prototype' ;
0453d815
PM
1171 sub freD() ;
1172 sub freD($) {}
1173}
1174sub FRED() ;
1175sub FRED($) {}
1176EXPECT
1177Prototype mismatch: sub main::fred () vs ($) at - line 4.
1178Prototype mismatch: sub main::freD () vs ($) at - line 11.
1179Prototype mismatch: sub main::FRED () vs ($) at - line 14.
eb6e2d6f 1180########
271c8bde
FC
1181# op.c [S_simplify_sort]
1182# [perl #86136]
1183my @tests = split /^/, '
1184 sort {$a <=> $b} @a;
1185 sort {$a cmp $b} @a;
1186 { use integer; sort {$a <=> $b} @a}
1187 sort {$b <=> $a} @a;
1188 sort {$b cmp $a} @a;
1189 { use integer; sort {$b <=> $a} @a}
1190';
1191for my $pragma ('use warnings "syntax";', '') {
1192 for my $vars ('', 'my $a;', 'my $b;', 'my ($a,$b);') {
1193 for my $inner_stmt ('', 'print;', 'func();') {
1194 eval "#line " . ++$line . "01 -\n$pragma\n$vars"
1195 . join "", map s/sort \{\K/$inner_stmt/r, @tests;
1196 $@ and die;
1197 }
1198 }
1199}
1200sub func{}
1201use warnings 'syntax';
1202my $a;
1203# These used to be errors!
1204sort { ; } $a <=> $b;
1205sort { ; } $a, "<=>";
1206sort { ; } $a, $cmp;
1207sort $a, $b if $cmpany_name;
1208sort if $a + $cmp;
1209sort @t; $a + $cmp;
1210EXPECT
1211"my $a" used in sort comparison at - line 403.
1212"my $a" used in sort comparison at - line 404.
1213"my $a" used in sort comparison at - line 405.
1214"my $a" used in sort comparison at - line 406.
1215"my $a" used in sort comparison at - line 407.
1216"my $a" used in sort comparison at - line 408.
1217"my $a" used in sort comparison at - line 503.
1218"my $a" used in sort comparison at - line 504.
1219"my $a" used in sort comparison at - line 505.
1220"my $a" used in sort comparison at - line 506.
1221"my $a" used in sort comparison at - line 507.
1222"my $a" used in sort comparison at - line 508.
1223"my $a" used in sort comparison at - line 603.
1224"my $a" used in sort comparison at - line 604.
1225"my $a" used in sort comparison at - line 605.
1226"my $a" used in sort comparison at - line 606.
1227"my $a" used in sort comparison at - line 607.
1228"my $a" used in sort comparison at - line 608.
1229"my $b" used in sort comparison at - line 703.
1230"my $b" used in sort comparison at - line 704.
1231"my $b" used in sort comparison at - line 705.
1232"my $b" used in sort comparison at - line 706.
1233"my $b" used in sort comparison at - line 707.
1234"my $b" used in sort comparison at - line 708.
1235"my $b" used in sort comparison at - line 803.
1236"my $b" used in sort comparison at - line 804.
1237"my $b" used in sort comparison at - line 805.
1238"my $b" used in sort comparison at - line 806.
1239"my $b" used in sort comparison at - line 807.
1240"my $b" used in sort comparison at - line 808.
1241"my $b" used in sort comparison at - line 903.
1242"my $b" used in sort comparison at - line 904.
1243"my $b" used in sort comparison at - line 905.
1244"my $b" used in sort comparison at - line 906.
1245"my $b" used in sort comparison at - line 907.
1246"my $b" used in sort comparison at - line 908.
1247"my $a" used in sort comparison at - line 1003.
1248"my $b" used in sort comparison at - line 1003.
1249"my $a" used in sort comparison at - line 1004.
1250"my $b" used in sort comparison at - line 1004.
1251"my $a" used in sort comparison at - line 1005.
1252"my $b" used in sort comparison at - line 1005.
1253"my $b" used in sort comparison at - line 1006.
1254"my $a" used in sort comparison at - line 1006.
1255"my $b" used in sort comparison at - line 1007.
1256"my $a" used in sort comparison at - line 1007.
1257"my $b" used in sort comparison at - line 1008.
1258"my $a" used in sort comparison at - line 1008.
1259"my $a" used in sort comparison at - line 1103.
1260"my $b" used in sort comparison at - line 1103.
1261"my $a" used in sort comparison at - line 1104.
1262"my $b" used in sort comparison at - line 1104.
1263"my $a" used in sort comparison at - line 1105.
1264"my $b" used in sort comparison at - line 1105.
1265"my $b" used in sort comparison at - line 1106.
1266"my $a" used in sort comparison at - line 1106.
1267"my $b" used in sort comparison at - line 1107.
1268"my $a" used in sort comparison at - line 1107.
1269"my $b" used in sort comparison at - line 1108.
1270"my $a" used in sort comparison at - line 1108.
1271"my $a" used in sort comparison at - line 1203.
1272"my $b" used in sort comparison at - line 1203.
1273"my $a" used in sort comparison at - line 1204.
1274"my $b" used in sort comparison at - line 1204.
1275"my $a" used in sort comparison at - line 1205.
1276"my $b" used in sort comparison at - line 1205.
1277"my $b" used in sort comparison at - line 1206.
1278"my $a" used in sort comparison at - line 1206.
1279"my $b" used in sort comparison at - line 1207.
1280"my $a" used in sort comparison at - line 1207.
1281"my $b" used in sort comparison at - line 1208.
1282"my $a" used in sort comparison at - line 1208.
1283########
a2e39214
FC
1284# op.c [S_simplify_sort]
1285use warnings 'syntax'; use 5.01;
1286state $a;
1287sort { $a <=> $b } ();
1288EXPECT
1289"state $a" used in sort comparison at - line 4.
1290########
89474f50
FC
1291# op.c [Perl_ck_cmp]
1292use warnings 'syntax' ;
1293no warnings 'deprecated';
1294@a = $[ < 5;
1295@a = $[ > 5;
1296@a = $[ <= 5;
1297@a = $[ >= 5;
1298@a = 42 < $[;
1299@a = 42 > $[;
1300@a = 42 <= $[;
1301@a = 42 >= $[;
1302use integer;
1303@a = $[ < 5;
1304@a = $[ > 5;
1305@a = $[ <= 5;
1306@a = $[ >= 5;
1307@a = 42 < $[;
1308@a = 42 > $[;
1309@a = 42 <= $[;
1310@a = 42 >= $[;
7c2b3c78
FC
1311no integer;
1312@a = $[ < $5;
1313@a = $[ > $5;
1314@a = $[ <= $5;
1315@a = $[ >= $5;
1316@a = $42 < $[;
1317@a = $42 > $[;
1318@a = $42 <= $[;
1319@a = $42 >= $[;
1320use integer;
1321@a = $[ < $5;
1322@a = $[ > $5;
1323@a = $[ <= $5;
1324@a = $[ >= $5;
1325@a = $42 < $[;
1326@a = $42 > $[;
1327@a = $42 <= $[;
1328@a = $42 >= $[;
89474f50
FC
1329EXPECT
1330$[ used in numeric lt (<) (did you mean $] ?) at - line 4.
1331$[ used in numeric gt (>) (did you mean $] ?) at - line 5.
1332$[ used in numeric le (<=) (did you mean $] ?) at - line 6.
1333$[ used in numeric ge (>=) (did you mean $] ?) at - line 7.
1334$[ used in numeric lt (<) (did you mean $] ?) at - line 8.
1335$[ used in numeric gt (>) (did you mean $] ?) at - line 9.
1336$[ used in numeric le (<=) (did you mean $] ?) at - line 10.
1337$[ used in numeric ge (>=) (did you mean $] ?) at - line 11.
1338$[ used in numeric lt (<) (did you mean $] ?) at - line 13.
1339$[ used in numeric gt (>) (did you mean $] ?) at - line 14.
1340$[ used in numeric le (<=) (did you mean $] ?) at - line 15.
1341$[ used in numeric ge (>=) (did you mean $] ?) at - line 16.
1342$[ used in numeric lt (<) (did you mean $] ?) at - line 17.
1343$[ used in numeric gt (>) (did you mean $] ?) at - line 18.
1344$[ used in numeric le (<=) (did you mean $] ?) at - line 19.
1345$[ used in numeric ge (>=) (did you mean $] ?) at - line 20.
1346########
0953b66b
FC
1347# op.c [Perl_ck_each]
1348$fred = {};
1349keys $fred;
1350values $fred;
1351each $fred;
d401967c 1352no warnings 'experimental::autoderef' ;
0953b66b
FC
1353keys $fred;
1354values $fred;
1355each $fred;
1356EXPECT
1357keys on reference is experimental at - line 3.
1358values on reference is experimental at - line 4.
1359each on reference is experimental at - line 5.
1360########
e508c8a4
MH
1361# op.c [Perl_ck_length]
1362use warnings 'syntax' ;
1363length(@a);
579333ee
FC
1364length(%b);
1365length(@$c);
1366length(%$d);
e508c8a4 1367length($a);
9710ad41 1368length(my %h);
579333ee 1369length(my @g);
e508c8a4 1370EXPECT
579333ee
FC
1371length() used on @a (did you mean "scalar(@a)"?) at - line 3.
1372length() used on %b (did you mean "scalar(keys %b)"?) at - line 4.
e508c8a4
MH
1373length() used on @array (did you mean "scalar(@array)"?) at - line 5.
1374length() used on %hash (did you mean "scalar(keys %hash)"?) at - line 6.
579333ee
FC
1375length() used on %h (did you mean "scalar(keys %h)"?) at - line 8.
1376length() used on @g (did you mean "scalar(@g)"?) at - line 9.
e508c8a4 1377########
eb6e2d6f
GS
1378# op.c
1379use warnings 'syntax' ;
1380join /---/, 'x', 'y', 'z';
1381EXPECT
1382/---/ should probably be written as "---" at - line 3.
767a6a26 1383########
ce16c625
BF
1384# op.c
1385use utf8;
1386use open qw( :utf8 :std );
1387use warnings 'syntax' ;
1388join /~~~/, 'x', 'y', 'z';
1389EXPECT
1390/~~~/ should probably be written as "~~~" at - line 5.
1391########
767a6a26 1392# op.c [Perl_peep]
e476b1b5 1393use warnings 'prototype' ;
767a6a26
PM
1394fred() ;
1395sub fred ($$) {}
e476b1b5 1396no warnings 'prototype' ;
767a6a26
PM
1397joe() ;
1398sub joe ($$) {}
1399EXPECT
1400main::fred() called too early to check prototype at - line 3.
ddda08b7
GS
1401########
1402# op.c [Perl_newATTRSUB]
1403--FILE-- abc.pm
1404use warnings 'void' ;
1405BEGIN { $| = 1; print "in begin\n"; }
1406CHECK { print "in check\n"; }
1407INIT { print "in init\n"; }
1408END { print "in end\n"; }
1409print "in mainline\n";
14101;
1411--FILE--
1412use abc;
1413delete $INC{"abc.pm"};
1414require abc;
1415do "abc.pm";
1416EXPECT
1417in begin
1418in mainline
1419in check
1420in init
1421in begin
1422Too late to run CHECK block at abc.pm line 3.
1423Too late to run INIT block at abc.pm line 4.
1424in mainline
1425in begin
1426Too late to run CHECK block at abc.pm line 3.
1427Too late to run INIT block at abc.pm line 4.
1428in mainline
1429in end
1430in end
1431in end
1432########
1433# op.c [Perl_newATTRSUB]
1434--FILE-- abc.pm
1435no warnings 'void' ;
1436BEGIN { $| = 1; print "in begin\n"; }
1437CHECK { print "in check\n"; }
1438INIT { print "in init\n"; }
1439END { print "in end\n"; }
1440print "in mainline\n";
14411;
1442--FILE--
1443require abc;
1444do "abc.pm";
1445EXPECT
1446in begin
1447in mainline
1448in begin
1449in mainline
1450in end
1451in end
936edb8b
RH
1452########
1453# op.c
1454my @x;
f87c3213 1455use warnings 'syntax' ;
936edb8b
RH
1456push(@x);
1457unshift(@x);
f87c3213 1458no warnings 'syntax' ;
936edb8b
RH
1459push(@x);
1460unshift(@x);
1461EXPECT
de4864e4
JH
1462Useless use of push with no values at - line 4.
1463Useless use of unshift with no values at - line 5.
a27978d3
AMS
1464########
1465# op.c
f34840d8
MJD
1466# 20020401 mjd@plover.com at suggestion of jfriedl@yahoo.com
1467use warnings 'regexp';
1468split /blah/g, "blah";
1469no warnings 'regexp';
1470split /blah/g, "blah";
1471EXPECT
1472Use of /g modifier is meaningless in split at - line 4.
276b2a0c
RGS
1473########
1474# op.c
1475use warnings 'precedence';
1476$a = $b & $c == $d;
1477$a = $b ^ $c != $d;
1478$a = $b | $c > $d;
1479$a = $b < $c & $d;
1480$a = $b >= $c ^ $d;
1481$a = $b <= $c | $d;
1482$a = $b <=> $c & $d;
2b84528b 1483$a &= $b == $c; $a |= $b == $c; $a ^= $b == $c; # shouldn't warn
276b2a0c
RGS
1484no warnings 'precedence';
1485$a = $b & $c == $d;
1486$a = $b ^ $c != $d;
1487$a = $b | $c > $d;
1488$a = $b < $c & $d;
1489$a = $b >= $c ^ $d;
1490$a = $b <= $c | $d;
1491$a = $b <=> $c & $d;
1492EXPECT
1493Possible precedence problem on bitwise & operator at - line 3.
1494Possible precedence problem on bitwise ^ operator at - line 4.
1495Possible precedence problem on bitwise | operator at - line 5.
1496Possible precedence problem on bitwise & operator at - line 6.
1497Possible precedence problem on bitwise ^ operator at - line 7.
1498Possible precedence problem on bitwise | operator at - line 8.
1499Possible precedence problem on bitwise & operator at - line 9.
1500########
1501# op.c
1502use integer;
1503use warnings 'precedence';
1504$a = $b & $c == $d;
1505$a = $b ^ $c != $d;
1506$a = $b | $c > $d;
1507$a = $b < $c & $d;
1508$a = $b >= $c ^ $d;
1509$a = $b <= $c | $d;
1510$a = $b <=> $c & $d;
1511no warnings 'precedence';
1512$a = $b & $c == $d;
1513$a = $b ^ $c != $d;
1514$a = $b | $c > $d;
1515$a = $b < $c & $d;
1516$a = $b >= $c ^ $d;
1517$a = $b <= $c | $d;
1518$a = $b <=> $c & $d;
1519EXPECT
1520Possible precedence problem on bitwise & operator at - line 4.
1521Possible precedence problem on bitwise ^ operator at - line 5.
1522Possible precedence problem on bitwise | operator at - line 6.
1523Possible precedence problem on bitwise & operator at - line 7.
1524Possible precedence problem on bitwise ^ operator at - line 8.
1525Possible precedence problem on bitwise | operator at - line 9.
1526Possible precedence problem on bitwise & operator at - line 10.
ddeae0f1
DM
1527########
1528# op.c
1529
1530# ok => local() has desired effect;
1531# ignore=> local() silently ignored
1532
1533use warnings 'syntax';
1534
1535local(undef); # OP_UNDEF ignore
1536sub lval : lvalue {};
1537local(lval()); # OP_ENTERSUB
1538local($x **= 1); # OP_POW
1539local($x *= 1); # OP_MULTIPLY
1540local($x /= 1); # OP_DIVIDE
1541local($x %= 1); # OP_MODULO
1542local($x x= 1); # OP_REPEAT
1543local($x += 1); # OP_ADD
1544local($x -= 1); # OP_SUBTRACT
1545local($x .= 1); # OP_CONCAT
1546local($x <<= 1); # OP_LEFT_SHIFT
1547local($x >>= 1); # OP_RIGHT_SHIFT
1548local($x &= 1); # OP_BIT_AND
1549local($x ^= 1); # OP_BIT_XOR
1550local($x |= 1); # OP_BIT_OR
1551{
1552 use integer;
1553 local($x *= 1); # OP_I_MULTIPLY
1554 local($x /= 1); # OP_I_DIVIDE
1555 local($x %= 1); # OP_I_MODULO
1556 local($x += 1); # OP_I_ADD
1557 local($x -= 1); # OP_I_SUBTRACT
1558}
1559local($x?$y:$z) = 1; # OP_COND_EXPR ok
1560# these two are fatal run-time errors instead
1561#local(@$a); # OP_RV2AV ok
1562#local(%$a); # OP_RV2HV ok
1563local(*a); # OP_RV2GV ok
1564local(@a[1,2]); # OP_ASLICE ok
1565local(@a{1,2}); # OP_HSLICE ok
1566local(@a = (1,2)); # OP_AASSIGN
1567local($$x); # OP_RV2SV ok
1568local($#a); # OP_AV2ARYLEN
1569local($x = 1); # OP_SASSIGN
1570local($x &&= 1); # OP_ANDASSIGN
1571local($x ||= 1); # OP_ORASSIGN
1572local($x //= 1); # OP_DORASSIGN
1573local($a[0]); # OP_AELEMFAST ok
1574
1575local(substr($x,0,1)); # OP_SUBSTR
1576local(pos($x)); # OP_POS
1577local(vec($x,0,1)); # OP_VEC
1578local($a[$b]); # OP_AELEM ok
1579local($a{$b}); # OP_HELEM ok
1580
1581no warnings 'syntax';
1582EXPECT
1583Useless localization of subroutine entry at - line 10.
1584Useless localization of exponentiation (**) at - line 11.
1585Useless localization of multiplication (*) at - line 12.
1586Useless localization of division (/) at - line 13.
1587Useless localization of modulus (%) at - line 14.
1588Useless localization of repeat (x) at - line 15.
1589Useless localization of addition (+) at - line 16.
1590Useless localization of subtraction (-) at - line 17.
1591Useless localization of concatenation (.) or string at - line 18.
1592Useless localization of left bitshift (<<) at - line 19.
1593Useless localization of right bitshift (>>) at - line 20.
1594Useless localization of bitwise and (&) at - line 21.
1595Useless localization of bitwise xor (^) at - line 22.
1596Useless localization of bitwise or (|) at - line 23.
1597Useless localization of integer multiplication (*) at - line 26.
1598Useless localization of integer division (/) at - line 27.
1599Useless localization of integer modulus (%) at - line 28.
1600Useless localization of integer addition (+) at - line 29.
1601Useless localization of integer subtraction (-) at - line 30.
1602Useless localization of list assignment at - line 39.
1603Useless localization of array length at - line 41.
1604Useless localization of scalar assignment at - line 42.
1605Useless localization of logical and assignment (&&=) at - line 43.
1606Useless localization of logical or assignment (||=) at - line 44.
1607Useless localization of defined or assignment (//=) at - line 45.
1608Useless localization of substr at - line 48.
1609Useless localization of match position at - line 49.
1610Useless localization of vec at - line 50.
7921d0f2
DM
1611########
1612# op.c
7921d0f2
DM
1613my $x1 if 0;
1614my @x2 if 0;
1615my %x3 if 0;
1616my ($x4) if 0;
1617my ($x5,@x6, %x7) if 0;
16180 && my $z1;
16190 && my (%z2);
1620# these shouldn't warn
1621our $x if 0;
1622our $x unless 0;
1623if (0) { my $w1 }
1624if (my $w2) { $a=1 }
1625if ($a && (my $w3 = 1)) {$a = 2}
1626
1627EXPECT
d1d15184 1628Deprecated use of my() in false conditional at - line 2.
7921d0f2
DM
1629Deprecated use of my() in false conditional at - line 3.
1630Deprecated use of my() in false conditional at - line 4.
1631Deprecated use of my() in false conditional at - line 5.
1632Deprecated use of my() in false conditional at - line 6.
1633Deprecated use of my() in false conditional at - line 7.
1634Deprecated use of my() in false conditional at - line 8.
55b67815
RGS
1635########
1636# op.c
36b2db7e
FC
1637$[ = 1;
1638($[) = 1;
1639use warnings 'deprecated';
1640$[ = 2;
1641($[) = 2;
1642no warnings 'deprecated';
1643$[ = 3;
1644($[) = 3;
1645EXPECT
1646Use of assignment to $[ is deprecated at - line 2.
1647Use of assignment to $[ is deprecated at - line 3.
1648Use of assignment to $[ is deprecated at - line 5.
1649Use of assignment to $[ is deprecated at - line 6.
1650########
1651# op.c
75068674
RGS
1652use warnings 'void';
1653@x = split /y/, "z";
1654$x = split /y/, "z";
1655 split /y/, "z";
1656no warnings 'void';
1657@x = split /y/, "z";
1658$x = split /y/, "z";
1659 split /y/, "z";
1660EXPECT
1661Useless use of split in void context at - line 5.
34ee6772
BF
1662########
1663# op.c
1664use warnings 'redefine' ;
1665use utf8;
1666use open qw( :utf8 :std );
1667sub frèd {}
1668sub frèd {}
1669no warnings 'redefine' ;
1670sub frèd {}
1671EXPECT
1672Subroutine frèd redefined at - line 6.
1673########
1674# op.c
1675use warnings 'redefine' ;
1676use utf8;
1677use open qw( :utf8 :std );
1678sub frèd () { 1 }
1679sub frèd () { 1 }
1680no warnings 'redefine' ;
1681sub frèd () { 1 }
1682EXPECT
1683Constant subroutine frèd redefined at - line 6.
1684########
1685# op.c
34ee6772
BF
1686use utf8;
1687use open qw( :utf8 :std );
1688sub frèd () { 1 }
1689sub frèd () { 2 }
1690EXPECT
efcf35c4 1691Constant subroutine frèd redefined at - line 5.
34ee6772
BF
1692########
1693# op.c
34ee6772
BF
1694use utf8;
1695use open qw( :utf8 :std );
1696sub frèd () { 1 }
1697*frèd = sub () { 2 };
1698EXPECT
efcf35c4 1699Constant subroutine main::frèd redefined at - line 5.
34ee6772
BF
1700########
1701# op.c
1702use warnings 'redefine' ;
1703use utf8;
1704use open qw( :utf8 :std );
1705sub ᚠርƊ {}
1706sub ᚠርƊ {}
1707no warnings 'redefine' ;
1708sub ᚠርƊ {}
1709EXPECT
1710Subroutine ᚠርƊ redefined at - line 6.
1711########
1712# op.c
1713use warnings 'redefine' ;
1714use utf8;
1715use open qw( :utf8 :std );
1716sub ᚠርƊ () { 1 }
1717sub ᚠርƊ () { 1 }
1718no warnings 'redefine' ;
1719sub ᚠርƊ () { 1 }
1720EXPECT
1721Constant subroutine ᚠርƊ redefined at - line 6.
1722########
1723# op.c
34ee6772
BF
1724use utf8;
1725use open qw( :utf8 :std );
1726sub ᚠርƊ () { 1 }
1727sub ᚠርƊ () { 2 }
1728EXPECT
efcf35c4 1729Constant subroutine ᚠርƊ redefined at - line 5.
34ee6772
BF
1730########
1731# op.c
34ee6772
BF
1732use utf8;
1733use open qw( :utf8 :std );
1734sub ᚠርƊ () { 1 }
1735*ᚠርƊ = sub () { 2 };
1736EXPECT
efcf35c4 1737Constant subroutine main::ᚠርƊ redefined at - line 5.
34ee6772 1738########
d787f4a5
NC
1739# OPTION regex
1740sub DynaLoader::dl_error {};
1741use warnings;
1742# We're testing that the warnings report the same line number:
1743eval <<'EOC' or die $@;
1744{
1745 DynaLoader::boot_DynaLoader("DynaLoader");
1746}
1747EOC
1748eval <<'EOC' or die $@;
1749BEGIN {
1750 DynaLoader::boot_DynaLoader("DynaLoader");
1751}
17521
1753EOC
1754EXPECT
1755OPTION regex
1756\ASubroutine DynaLoader::dl_error redefined at \(eval 1\) line 2\.
b5ab070a 1757?(?s).*
d787f4a5
NC
1758Subroutine DynaLoader::dl_error redefined at \(eval 2\) line 2\.
1759########
9da2d046
NT
1760# op.c
1761use warnings;
1762sub do_warn_1 { return $a or $b; }
1763sub do_warn_2 { return $a and $b; }
1764sub do_warn_3 { return $a xor $b; }
1765sub do_warn_4 { die $a or $b; }
1766sub do_warn_5 { die $a and $b; }
1767sub do_warn_6 { die $a xor $b; }
1768sub do_warn_7 { exit $a or $b; }
1769sub do_warn_8 { exit $a and $b; }
1770sub do_warn_9 { exit $a xor $b; }
1771
1772# Since exit is an unary operator, it is even stronger than
1773# || and &&.
1774sub do_warn_10 { exit $a || $b; }
1775sub do_warn_11 { exit $a && $b; }
1776
1777sub do_warn_12 { goto $a or $b; }
1778sub do_warn_13 { goto $a and $b; }
1779sub do_warn_14 { goto $a xor $b; }
1780sub do_warn_15 { next $a or $b while(1); }
1781sub do_warn_16 { next $a and $b while(1); }
1782sub do_warn_17 { next $a xor $b while(1); }
1783sub do_warn_18 { last $a or $b while(1); }
1784sub do_warn_19 { last $a and $b while(1); }
1785sub do_warn_20 { last $a xor $b while(1); }
1786sub do_warn_21 { redo $a or $b while(1); }
1787sub do_warn_22 { redo $a and $b while(1); }
1788sub do_warn_23 { redo $a xor $b while(1); }
1789# These get re-written to "(return/die $a) and $b"
1790sub do_warn_24 { $b if return $a; }
1791sub do_warn_25 { $b if die $a; }
1792EXPECT
1793Possible precedence issue with control flow operator at - line 3.
1794Possible precedence issue with control flow operator at - line 4.
1795Possible precedence issue with control flow operator at - line 5.
1796Possible precedence issue with control flow operator at - line 6.
1797Possible precedence issue with control flow operator at - line 7.
1798Possible precedence issue with control flow operator at - line 8.
1799Possible precedence issue with control flow operator at - line 9.
1800Possible precedence issue with control flow operator at - line 10.
1801Possible precedence issue with control flow operator at - line 11.
1802Possible precedence issue with control flow operator at - line 15.
1803Possible precedence issue with control flow operator at - line 16.
1804Possible precedence issue with control flow operator at - line 18.
1805Possible precedence issue with control flow operator at - line 19.
1806Possible precedence issue with control flow operator at - line 20.
1807Possible precedence issue with control flow operator at - line 21.
1808Possible precedence issue with control flow operator at - line 22.
1809Possible precedence issue with control flow operator at - line 23.
1810Possible precedence issue with control flow operator at - line 24.
1811Possible precedence issue with control flow operator at - line 25.
1812Possible precedence issue with control flow operator at - line 26.
1813Possible precedence issue with control flow operator at - line 27.
1814Possible precedence issue with control flow operator at - line 28.
1815Possible precedence issue with control flow operator at - line 29.
1816Possible precedence issue with control flow operator at - line 31.
1817Possible precedence issue with control flow operator at - line 32.
1818########
1819# op.c
1820# (same as above, except these should not warn)
1821use constant FEATURE => 1;
1822use constant MISSING_FEATURE => 0;
1823
1824sub dont_warn_1 { MISSING_FEATURE and return or dont_warn_3(); }
1825sub dont_warn_2 { FEATURE || return and dont_warn_3(); }
1826sub dont_warn_3 { not FEATURE and return or dont_warn_3(); }
1827sub dont_warn_4 { !MISSING_FEATURE || return and dont_warn_3(); }
1828sub dont_warn_5 { MISSING_FEATURE and die or dont_warn_3(); }
1829sub dont_warn_6 { FEATURE || die and dont_warn_3(); }
1830sub dont_warn_7 { not FEATURE and die or dont_warn_3(); }
1831sub dont_warn_8 { !MISSING_FEATURE || die and dont_warn_3(); }
1832sub dont_warn_9 { MISSING_FEATURE and goto $a or dont_warn_3(); }
1833sub dont_warn_10 { FEATURE || goto $a and dont_warn_3(); }
1834sub dont_warn_11 { not FEATURE and goto $a or dont_warn_3(); }
1835sub dont_warn_12 { !MISSING_FEATURE || goto $a and dont_warn_3(); }
1836
1837sub dont_warn_13 { MISSING_FEATURE and exit $a or dont_warn_3(); }
1838sub dont_warn_14 { FEATURE || exit $a and dont_warn_3(); }
1839sub dont_warn_15 { not FEATURE and exit $a or dont_warn_3(); }
1840sub dont_warn_16 { !MISSING_FEATURE || exit $a and dont_warn_3(); }
1841
1842sub dont_warn_17 { MISSING_FEATURE and next or dont_warn_3() while(1); }
1843sub dont_warn_18 { FEATURE || next and dont_warn_3() while(1); }
1844sub dont_warn_19 { not FEATURE and next or dont_warn_3() while(1); }
1845sub dont_warn_20 { !MISSING_FEATURE || next and dont_warn_3() while(1); }
1846sub dont_warn_21 { MISSING_FEATURE and redo or dont_warn_3() while(1); }
1847sub dont_warn_22 { FEATURE || redo and dont_warn_3() while(1); }
1848sub dont_warn_23 { not FEATURE and redo or dont_warn_3() while(1); }
1849sub dont_warn_24 { !MISSING_FEATURE || redo and dont_warn_3() while(1); }
1850sub dont_warn_25 { MISSING_FEATURE and last or dont_warn_3() while(1); }
1851sub dont_warn_26 { FEATURE || last and dont_warn_3() while(1); }
1852sub dont_warn_27 { not FEATURE and last or dont_warn_3() while(1); }
1853sub dont_warn_28 { !MISSING_FEATURE || last and dont_warn_3() while(1); }
1854
1855# These are weird, but at least not ambiguous.
1856sub dont_warn_29 { return ($a or $b); }
1857sub dont_warn_30 { return ($a and $b); }
1858sub dont_warn_31 { return ($a xor $b); }
1859sub dont_warn_32 { die ($a or $b); }
1860sub dont_warn_33 { die ($a and $b); }
1861sub dont_warn_34 { die ($a xor $b); }
1862sub dont_warn_35 { goto ($a or $b); }
1863sub dont_warn_36 { goto ($a and $b); }
1864sub dont_warn_37 { goto ($a xor $b); }
1865sub dont_warn_38 { next ($a or $b) while(1); }
1866sub dont_warn_39 { next ($a and $b) while(1); }
1867sub dont_warn_40 { next ($a xor $b) while(1); }
1868sub dont_warn_41 { last ($a or $b) while(1); }
1869sub dont_warn_42 { last ($a and $b) while(1); }
1870sub dont_warn_43 { last ($a xor $b) while(1); }
1871sub dont_warn_44 { redo ($a or $b) while(1); }
1872sub dont_warn_45 { redo ($a and $b) while(1); }
1873sub dont_warn_46 { redo ($a xor $b) while(1); }
1874EXPECT
30d9c59b
Z
1875########
1876use feature "signatures";
1877sub aaa { 2 }
1878sub bbb ($a) { 4 }
1879$aaa = sub { 2 };
1880$bbb = sub ($a) { 4 };
1881EXPECT
1882The signatures feature is experimental at - line 3.
1883The signatures feature is experimental at - line 5.
1884########
1885no warnings "experimental::signatures";
1886use feature "signatures";
1887sub aaa { 2 }
1888sub bbb ($a) { 4 }
1889$aaa = sub { 2 };
1890$bbb = sub ($a) { 4 };
1891EXPECT