This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove ‘Runaway prototype’ warning
[perl5.git] / t / lib / warnings / op
CommitLineData
599cee73
PM
1 op.c AOK
2
599cee73
PM
3 Found = in conditional, should be ==
4 1 if $a = 1 ;
5
599cee73
PM
6 Useless use of time in void context
7 Useless use of a variable in void context
8 Useless use of a constant in void context
9 time ;
10 $a ;
11 "abc"
12
a801c63c
RGS
13 Useless use of sort in scalar context
14 my $x = sort (2,1,3);
15
599cee73
PM
16 Applying %s to %s will act on scalar(%s)
17 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
18 @a =~ /abc/ ;
19 @a =~ s/a/b/ ;
20 @a =~ tr/a/b/ ;
21 @$b =~ /abc/ ;
22 @$b =~ s/a/b/ ;
23 @$b =~ tr/a/b/ ;
24 %a =~ /abc/ ;
25 %a =~ s/a/b/ ;
26 %a =~ tr/a/b/ ;
27 %$c =~ /abc/ ;
28 %$c =~ s/a/b/ ;
29 %$c =~ tr/a/b/ ;
30
31
df5b6949 32 Parentheses missing around "my" list at -e line 1.
599cee73
PM
33 my $a, $b = (1,2);
34
df5b6949 35 Parentheses missing around "local" list at -e line 1.
599cee73
PM
36 local $a, $b = (1,2);
37
34d09196 38 Bareword found in conditional at -e line 1.
e476b1b5 39 use warnings 'bareword'; my $x = print(ABC || 1);
599cee73
PM
40
41 Value of %s may be \"0\"; use \"defined\"
42 $x = 1 if $x = <FH> ;
43 $x = 1 while $x = <FH> ;
44
45 Subroutine fred redefined at -e line 1.
46 sub fred{1;} sub fred{1;}
47
48 Constant subroutine %s redefined
49 sub fred() {1;} sub fred() {1;}
50
51 Format FRED redefined at /tmp/x line 5.
52 format FRED =
53 .
54 format FRED =
55 .
56
57 Array @%s missing the @ in argument %d of %s()
58 push fred ;
59
60 Hash %%%s missing the %% in argument %d of %s()
61 keys joe ;
62
63 Statement unlikely to be reached
cc507455 64 (Maybe you meant system() when you said exec()?
599cee73
PM
65 exec "true" ; my $a
66
f10b0346 67 defined(@array) is deprecated
cc507455 68 (Maybe you should just omit the defined()?)
69794302
MJD
69 my @a ; defined @a ;
70 defined (@a = (1,2,3)) ;
71
f10b0346 72 defined(%hash) is deprecated
cc507455 73 (Maybe you should just omit the defined()?)
69794302 74 my %h ; defined %h ;
89474f50
FC
75
76 $[ used in comparison (did you mean $] ?)
e508c8a4
MH
77
78 length() used on @array (did you mean "scalar(@array)"?)
79 length() used on %hash (did you mean "scalar(keys %hash)"?)
80
eb6e2d6f
GS
81 /---/ should probably be written as "---"
82 join(/---/, @foo);
599cee73 83
767a6a26
PM
84 %s() called too early to check prototype [Perl_peep]
85 fred() ; sub fred ($$) {}
86
87
15a8c21e 88 Package '%s' not found (did you use the incorrect case?)
3b434eb1 89
f34840d8
MJD
90 Use of /g modifier is meaningless in split
91
276b2a0c
RGS
92 Possible precedence problem on bitwise %c operator [Perl_ck_bitop]
93
0453d815
PM
94 Mandatory Warnings
95 ------------------
96 Prototype mismatch: [cv_ckproto]
97 sub fred() ;
98 sub fred($) {}
99
0453d815
PM
100 oops: oopsAV [oopsAV] TODO
101 oops: oopsHV [oopsHV] TODO
102
599cee73
PM
103__END__
104# op.c
4438c4b7 105use warnings 'syntax' ;
599cee73 1061 if $a = 1 ;
4438c4b7 107no warnings 'syntax' ;
0453d815 1081 if $a = 1 ;
599cee73
PM
109EXPECT
110Found = in conditional, should be == at - line 3.
111########
112# op.c
6b7c6d95
FC
113use warnings 'syntax' ;
114use constant foo => 1;
1151 if $a = foo ;
116no warnings 'syntax' ;
1171 if $a = foo ;
118EXPECT
119########
120# op.c
a1063b2d
RH
121my (@foo, %foo);
122%main::foo->{"bar"};
123%foo->{"bar"};
124@main::foo->[23];
125@foo->[23];
126$main::foo = {}; %$main::foo->{"bar"};
127$foo = {}; %$foo->{"bar"};
128$main::foo = []; @$main::foo->[34];
129$foo = []; @$foo->[34];
130no warnings 'deprecated';
131%main::foo->{"bar"};
132%foo->{"bar"};
133@main::foo->[23];
134@foo->[23];
135$main::foo = {}; %$main::foo->{"bar"};
136$foo = {}; %$foo->{"bar"};
137$main::foo = []; @$main::foo->[34];
138$foo = []; @$foo->[34];
139EXPECT
d1d15184 140Using a hash as a reference is deprecated at - line 3.
a1063b2d 141Using a hash as a reference is deprecated at - line 4.
d1d15184 142Using an array as a reference is deprecated at - line 5.
a1063b2d 143Using an array as a reference is deprecated at - line 6.
d1d15184 144Using a hash as a reference is deprecated at - line 7.
a1063b2d 145Using a hash as a reference is deprecated at - line 8.
d1d15184 146Using an array as a reference is deprecated at - line 9.
a1063b2d 147Using an array as a reference is deprecated at - line 10.
a1063b2d
RH
148########
149# op.c
4438c4b7 150use warnings 'void' ; close STDIN ;
599cee73
PM
1511 x 3 ; # OP_REPEAT
152 # OP_GVSV
153wantarray ; # OP_WANTARRAY
154 # OP_GV
155 # OP_PADSV
156 # OP_PADAV
157 # OP_PADHV
158 # OP_PADANY
159 # OP_AV2ARYLEN
160ref ; # OP_REF
161\@a ; # OP_REFGEN
162\$a ; # OP_SREFGEN
163defined $a ; # OP_DEFINED
164hex $a ; # OP_HEX
165oct $a ; # OP_OCT
166length $a ; # OP_LENGTH
167substr $a,1 ; # OP_SUBSTR
168vec $a,1,2 ; # OP_VEC
169index $a,1,2 ; # OP_INDEX
170rindex $a,1,2 ; # OP_RINDEX
171sprintf $a ; # OP_SPRINTF
172$a[0] ; # OP_AELEM
173 # OP_AELEMFAST
174@a[0] ; # OP_ASLICE
175#values %a ; # OP_VALUES
176#keys %a ; # OP_KEYS
177$a{0} ; # OP_HELEM
178@a{0} ; # OP_HSLICE
179unpack "a", "a" ; # OP_UNPACK
180pack $a,"" ; # OP_PACK
181join "" ; # OP_JOIN
182(@a)[0,1] ; # OP_LSLICE
183 # OP_ANONLIST
184 # OP_ANONHASH
185sort(1,2) ; # OP_SORT
186reverse(1,2) ; # OP_REVERSE
187 # OP_RANGE
188 # OP_FLIP
189(1 ..2) ; # OP_FLOP
190caller ; # OP_CALLER
191fileno STDIN ; # OP_FILENO
192eof STDIN ; # OP_EOF
193tell STDIN ; # OP_TELL
194readlink 1; # OP_READLINK
195time ; # OP_TIME
196localtime ; # OP_LOCALTIME
197gmtime ; # OP_GMTIME
dfe13c55
GS
198eval { getgrnam 1 }; # OP_GGRNAM
199eval { getgrgid 1 }; # OP_GGRGID
200eval { getpwnam 1 }; # OP_GPWNAM
201eval { getpwuid 1 }; # OP_GPWUID
78e1b766 202prototype "foo"; # OP_PROTOTYPE
74295f0b
MS
203$a ~~ $b; # OP_SMARTMATCH
204$a <=> $b; # OP_NCMP
703227f5
FC
205use 5.015;
206__SUB__ # OP_RUNCV
599cee73 207EXPECT
42d38218 208Useless use of repeat (x) in void context at - line 3.
599cee73
PM
209Useless use of wantarray in void context at - line 5.
210Useless use of reference-type operator in void context at - line 12.
211Useless use of reference constructor in void context at - line 13.
d6c467eb 212Useless use of single ref constructor in void context at - line 14.
599cee73
PM
213Useless use of defined operator in void context at - line 15.
214Useless use of hex in void context at - line 16.
215Useless use of oct in void context at - line 17.
216Useless use of length in void context at - line 18.
217Useless use of substr in void context at - line 19.
218Useless use of vec in void context at - line 20.
219Useless use of index in void context at - line 21.
220Useless use of rindex in void context at - line 22.
221Useless use of sprintf in void context at - line 23.
222Useless use of array element in void context at - line 24.
223Useless use of array slice in void context at - line 26.
f1612b5c 224Useless use of hash element in void context at - line 29.
599cee73
PM
225Useless use of hash slice in void context at - line 30.
226Useless use of unpack in void context at - line 31.
227Useless use of pack in void context at - line 32.
297b36dc 228Useless use of join or string in void context at - line 33.
599cee73
PM
229Useless use of list slice in void context at - line 34.
230Useless use of sort in void context at - line 37.
231Useless use of reverse in void context at - line 38.
232Useless use of range (or flop) in void context at - line 41.
233Useless use of caller in void context at - line 42.
234Useless use of fileno in void context at - line 43.
235Useless use of eof in void context at - line 44.
236Useless use of tell in void context at - line 45.
237Useless use of readlink in void context at - line 46.
238Useless use of time in void context at - line 47.
239Useless use of localtime in void context at - line 48.
240Useless use of gmtime in void context at - line 49.
241Useless use of getgrnam in void context at - line 50.
242Useless use of getgrgid in void context at - line 51.
243Useless use of getpwnam in void context at - line 52.
244Useless use of getpwuid in void context at - line 53.
78e1b766 245Useless use of subroutine prototype in void context at - line 54.
f5df4782
RGS
246Useless use of smart match in void context at - line 55.
247Useless use of numeric comparison (<=>) in void context at - line 56.
703227f5 248Useless use of __SUB__ in void context at - line 58.
599cee73
PM
249########
250# op.c
a801c63c
RGS
251use warnings 'void' ; close STDIN ;
252my $x = sort (2,1,3);
253no warnings 'void' ;
254$x = sort (2,1,3);
255EXPECT
256Useless use of sort in scalar context at - line 3.
257########
258# op.c
4438c4b7 259no warnings 'void' ; close STDIN ;
0453d815
PM
2601 x 3 ; # OP_REPEAT
261 # OP_GVSV
262wantarray ; # OP_WANTARRAY
263 # OP_GV
264 # OP_PADSV
265 # OP_PADAV
266 # OP_PADHV
267 # OP_PADANY
268 # OP_AV2ARYLEN
269ref ; # OP_REF
270\@a ; # OP_REFGEN
271\$a ; # OP_SREFGEN
272defined $a ; # OP_DEFINED
273hex $a ; # OP_HEX
274oct $a ; # OP_OCT
275length $a ; # OP_LENGTH
276substr $a,1 ; # OP_SUBSTR
277vec $a,1,2 ; # OP_VEC
278index $a,1,2 ; # OP_INDEX
279rindex $a,1,2 ; # OP_RINDEX
280sprintf $a ; # OP_SPRINTF
281$a[0] ; # OP_AELEM
282 # OP_AELEMFAST
283@a[0] ; # OP_ASLICE
284#values %a ; # OP_VALUES
285#keys %a ; # OP_KEYS
286$a{0} ; # OP_HELEM
287@a{0} ; # OP_HSLICE
288unpack "a", "a" ; # OP_UNPACK
289pack $a,"" ; # OP_PACK
290join "" ; # OP_JOIN
291(@a)[0,1] ; # OP_LSLICE
292 # OP_ANONLIST
293 # OP_ANONHASH
294sort(1,2) ; # OP_SORT
295reverse(1,2) ; # OP_REVERSE
296 # OP_RANGE
297 # OP_FLIP
298(1 ..2) ; # OP_FLOP
299caller ; # OP_CALLER
300fileno STDIN ; # OP_FILENO
301eof STDIN ; # OP_EOF
302tell STDIN ; # OP_TELL
303readlink 1; # OP_READLINK
304time ; # OP_TIME
305localtime ; # OP_LOCALTIME
306gmtime ; # OP_GMTIME
307eval { getgrnam 1 }; # OP_GGRNAM
308eval { getgrgid 1 }; # OP_GGRGID
309eval { getpwnam 1 }; # OP_GPWNAM
310eval { getpwuid 1 }; # OP_GPWUID
78e1b766 311prototype "foo"; # OP_PROTOTYPE
0453d815
PM
312EXPECT
313########
314# op.c
4438c4b7 315use warnings 'void' ;
68c73484 316for (@{[0]}) { "$_" } # check warning isn't duplicated
4438c4b7 317no warnings 'void' ;
0453d815 318for (@{[0]}) { "$_" } # check warning isn't duplicated
68c73484
JH
319EXPECT
320Useless use of string in void context at - line 3.
321########
322# op.c
4438c4b7 323use warnings 'void' ;
599cee73
PM
324use Config ;
325BEGIN {
326 if ( ! $Config{d_telldir}) {
327 print <<EOM ;
328SKIPPED
329# telldir not present
330EOM
331 exit
332 }
333}
334telldir 1 ; # OP_TELLDIR
4438c4b7 335no warnings 'void' ;
0453d815 336telldir 1 ; # OP_TELLDIR
599cee73
PM
337EXPECT
338Useless use of telldir in void context at - line 13.
339########
340# op.c
4438c4b7 341use warnings 'void' ;
599cee73
PM
342use Config ;
343BEGIN {
344 if ( ! $Config{d_getppid}) {
345 print <<EOM ;
346SKIPPED
347# getppid not present
348EOM
349 exit
350 }
351}
352getppid ; # OP_GETPPID
4438c4b7 353no warnings 'void' ;
0453d815 354getppid ; # OP_GETPPID
599cee73
PM
355EXPECT
356Useless use of getppid in void context at - line 13.
357########
358# op.c
4438c4b7 359use warnings 'void' ;
599cee73
PM
360use Config ;
361BEGIN {
362 if ( ! $Config{d_getpgrp}) {
363 print <<EOM ;
364SKIPPED
365# getpgrp not present
366EOM
367 exit
368 }
369}
370getpgrp ; # OP_GETPGRP
4438c4b7 371no warnings 'void' ;
0453d815 372getpgrp ; # OP_GETPGRP
599cee73
PM
373EXPECT
374Useless use of getpgrp in void context at - line 13.
375########
376# op.c
4438c4b7 377use warnings 'void' ;
599cee73
PM
378use Config ;
379BEGIN {
380 if ( ! $Config{d_times}) {
381 print <<EOM ;
382SKIPPED
383# times not present
384EOM
385 exit
386 }
387}
388times ; # OP_TMS
4438c4b7 389no warnings 'void' ;
0453d815 390times ; # OP_TMS
599cee73
PM
391EXPECT
392Useless use of times in void context at - line 13.
393########
394# op.c
4438c4b7 395use warnings 'void' ;
599cee73
PM
396use Config ;
397BEGIN {
e96326af 398 if ( ! $Config{d_getprior} or $^O eq 'os2') { # Locks before fixpak22
599cee73
PM
399 print <<EOM ;
400SKIPPED
401# getpriority not present
402EOM
403 exit
404 }
405}
406getpriority 1,2; # OP_GETPRIORITY
4438c4b7 407no warnings 'void' ;
0453d815 408getpriority 1,2; # OP_GETPRIORITY
599cee73
PM
409EXPECT
410Useless use of getpriority in void context at - line 13.
411########
412# op.c
4438c4b7 413use warnings 'void' ;
599cee73
PM
414use Config ;
415BEGIN {
416 if ( ! $Config{d_getlogin}) {
417 print <<EOM ;
418SKIPPED
419# getlogin not present
420EOM
421 exit
422 }
423}
424getlogin ; # OP_GETLOGIN
4438c4b7 425no warnings 'void' ;
0453d815 426getlogin ; # OP_GETLOGIN
599cee73
PM
427EXPECT
428Useless use of getlogin in void context at - line 13.
429########
430# op.c
4438c4b7 431use warnings 'void' ;
599cee73
PM
432use Config ; BEGIN {
433if ( ! $Config{d_socket}) {
434 print <<EOM ;
435SKIPPED
436# getsockname not present
437# getpeername not present
438# gethostbyname not present
439# gethostbyaddr not present
440# gethostent not present
441# getnetbyname not present
442# getnetbyaddr not present
443# getnetent not present
444# getprotobyname not present
445# getprotobynumber not present
446# getprotoent not present
447# getservbyname not present
448# getservbyport not present
449# getservent not present
450EOM
451 exit
452} }
453getsockname STDIN ; # OP_GETSOCKNAME
454getpeername STDIN ; # OP_GETPEERNAME
455gethostbyname 1 ; # OP_GHBYNAME
456gethostbyaddr 1,2; # OP_GHBYADDR
457gethostent ; # OP_GHOSTENT
458getnetbyname 1 ; # OP_GNBYNAME
459getnetbyaddr 1,2 ; # OP_GNBYADDR
460getnetent ; # OP_GNETENT
461getprotobyname 1; # OP_GPBYNAME
462getprotobynumber 1; # OP_GPBYNUMBER
463getprotoent ; # OP_GPROTOENT
464getservbyname 1,2; # OP_GSBYNAME
465getservbyport 1,2; # OP_GSBYPORT
466getservent ; # OP_GSERVENT
0453d815 467
4438c4b7 468no warnings 'void' ;
0453d815
PM
469getsockname STDIN ; # OP_GETSOCKNAME
470getpeername STDIN ; # OP_GETPEERNAME
471gethostbyname 1 ; # OP_GHBYNAME
472gethostbyaddr 1,2; # OP_GHBYADDR
473gethostent ; # OP_GHOSTENT
474getnetbyname 1 ; # OP_GNBYNAME
475getnetbyaddr 1,2 ; # OP_GNBYADDR
476getnetent ; # OP_GNETENT
477getprotobyname 1; # OP_GPBYNAME
478getprotobynumber 1; # OP_GPBYNUMBER
479getprotoent ; # OP_GPROTOENT
480getservbyname 1,2; # OP_GSBYNAME
481getservbyport 1,2; # OP_GSBYPORT
482getservent ; # OP_GSERVENT
dfe13c55
GS
483INIT {
484 # some functions may not be there, so we exit without running
485 exit;
486}
599cee73
PM
487EXPECT
488Useless use of getsockname in void context at - line 24.
489Useless use of getpeername in void context at - line 25.
490Useless use of gethostbyname in void context at - line 26.
491Useless use of gethostbyaddr in void context at - line 27.
492Useless use of gethostent in void context at - line 28.
493Useless use of getnetbyname in void context at - line 29.
494Useless use of getnetbyaddr in void context at - line 30.
495Useless use of getnetent in void context at - line 31.
496Useless use of getprotobyname in void context at - line 32.
497Useless use of getprotobynumber in void context at - line 33.
498Useless use of getprotoent in void context at - line 34.
499Useless use of getservbyname in void context at - line 35.
500Useless use of getservbyport in void context at - line 36.
501Useless use of getservent in void context at - line 37.
502########
503# op.c
4438c4b7 504use warnings 'void' ;
599cee73
PM
505*a ; # OP_RV2GV
506$a ; # OP_RV2SV
507@a ; # OP_RV2AV
508%a ; # OP_RV2HV
4438c4b7 509no warnings 'void' ;
0453d815
PM
510*a ; # OP_RV2GV
511$a ; # OP_RV2SV
512@a ; # OP_RV2AV
513%a ; # OP_RV2HV
599cee73
PM
514EXPECT
515Useless use of a variable in void context at - line 3.
516Useless use of a variable in void context at - line 4.
517Useless use of a variable in void context at - line 5.
518Useless use of a variable in void context at - line 6.
519########
520# op.c
4438c4b7 521use warnings 'void' ;
599cee73
PM
522"abc"; # OP_CONST
5237 ; # OP_CONST
86f9315f
RD
524"x" . "y"; # optimized to OP_CONST
5252 + 2; # optimized to OP_CONST
e7fec78e 526use constant U => undef;
fa01e093 527U;
919f76a3 528qq/" \n/;
fa01e093 5295 || print "bad\n"; # test OPpCONST_SHORTCIRCUIT
e7fec78e 530print "boo\n" if U; # test OPpCONST_SHORTCIRCUIT
4438c4b7 531no warnings 'void' ;
0453d815
PM
532"abc"; # OP_CONST
5337 ; # OP_CONST
86f9315f
RD
534"x" . "y"; # optimized to OP_CONST
5352 + 2; # optimized to OP_CONST
599cee73 536EXPECT
919f76a3 537Useless use of a constant ("abc") in void context at - line 3.
86f9315f 538Useless use of a constant (7) in void context at - line 4.
919f76a3 539Useless use of a constant ("xy") in void context at - line 5.
86f9315f 540Useless use of a constant (4) in void context at - line 6.
fa01e093 541Useless use of a constant (undef) in void context at - line 8.
919f76a3 542Useless use of a constant ("\"\t\n") in void context at - line 9.
599cee73
PM
543########
544# op.c
34ee6772
BF
545use utf8;
546use open qw( :utf8 :std );
547use warnings 'void' ;
548"àḆc"; # OP_CONST
549"Ẋ" . "ƴ"; # optimized to OP_CONST
550FOO; # Bareword optimized to OP_CONST
551use constant ů => undef;
552ů;
5535 || print "bad\n"; # test OPpCONST_SHORTCIRCUIT
554print "boo\n" if ů; # test OPpCONST_SHORTCIRCUIT
555no warnings 'void' ;
556"àḆc"; # OP_CONST
557"Ẋ" . "ƴ"; # optimized to OP_CONST
558EXPECT
919f76a3
RGS
559Useless use of a constant ("\340\x{1e06}c") in void context at - line 5.
560Useless use of a constant ("\x{1e8a}\x{1b4}") in void context at - line 6.
561Useless use of a constant ("\x{ff26}\x{ff2f}\x{ff2f}") in void context at - line 7.
34ee6772
BF
562Useless use of a constant (undef) in void context at - line 9.
563########
564# op.c
7f01dc7a 565#
e476b1b5 566use warnings 'misc' ;
b08e453b 567my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;my $d = 'test';
599cee73 568@a =~ /abc/ ;
c6771ab6
FC
569@a2 =~ s/a/b/ ;
570@a3 =~ tr/a/b/ ;
599cee73
PM
571@$b =~ /abc/ ;
572@$b =~ s/a/b/ ;
573@$b =~ tr/a/b/ ;
574%a =~ /abc/ ;
c6771ab6
FC
575%a2 =~ s/a/b/ ;
576%a3 =~ tr/a/b/ ;
599cee73
PM
577%$c =~ /abc/ ;
578%$c =~ s/a/b/ ;
579%$c =~ tr/a/b/ ;
b08e453b 580$d =~ tr/a/b/d ;
c6771ab6 581$d2 =~ tr/a/bc/;
0453d815 582{
e476b1b5 583no warnings 'misc' ;
b08e453b 584my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ; my $d = 'test';
0453d815
PM
585@a =~ /abc/ ;
586@a =~ s/a/b/ ;
587@a =~ tr/a/b/ ;
588@$b =~ /abc/ ;
589@$b =~ s/a/b/ ;
590@$b =~ tr/a/b/ ;
591%a =~ /abc/ ;
592%a =~ s/a/b/ ;
593%a =~ tr/a/b/ ;
594%$c =~ /abc/ ;
595%$c =~ s/a/b/ ;
596%$c =~ tr/a/b/ ;
b08e453b 597$d =~ tr/a/b/d ;
598$d =~ tr/a/bc/ ;
0453d815 599}
599cee73 600EXPECT
c6771ab6
FC
601Applying pattern match (m//) to @a will act on scalar(@a) at - line 5.
602Applying substitution (s///) to @a2 will act on scalar(@a2) at - line 6.
603Applying transliteration (tr///) to @a3 will act on scalar(@a3) at - line 7.
42d38218
MS
604Applying pattern match (m//) to @array will act on scalar(@array) at - line 8.
605Applying substitution (s///) to @array will act on scalar(@array) at - line 9.
f1612b5c 606Applying transliteration (tr///) to @array will act on scalar(@array) at - line 10.
c6771ab6
FC
607Applying pattern match (m//) to %a will act on scalar(%a) at - line 11.
608Applying substitution (s///) to %a2 will act on scalar(%a2) at - line 12.
609Applying transliteration (tr///) to %a3 will act on scalar(%a3) at - line 13.
42d38218
MS
610Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 14.
611Applying substitution (s///) to %hash will act on scalar(%hash) at - line 15.
f1612b5c 612Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 16.
b08e453b 613Useless use of /d modifier in transliteration operator at - line 17.
614Replacement list is longer than search list at - line 18.
c6771ab6 615Can't modify array dereference in substitution (s///) at - line 6, near "s/a/b/ ;"
b08e453b 616BEGIN not safe after errors--compilation aborted at - line 20.
599cee73
PM
617########
618# op.c
8473848f 619use warnings 'parenthesis' ;
599cee73 620my $a, $b = (1,2);
8473848f 621my @foo,%bar, $quux; # there's a TAB here
bac662ee 622my $x, $y or print;
8473848f 623no warnings 'parenthesis' ;
0453d815 624my $c, $d = (1,2);
599cee73 625EXPECT
df5b6949 626Parentheses missing around "my" list at - line 3.
8473848f 627Parentheses missing around "my" list at - line 4.
599cee73
PM
628########
629# op.c
8473848f
RGS
630use warnings 'parenthesis' ;
631our $a, $b = (1,2);
632no warnings 'parenthesis' ;
633our $c, $d = (1,2);
634EXPECT
635Parentheses missing around "our" list at - line 3.
636########
637# op.c
638use warnings 'parenthesis' ;
599cee73 639local $a, $b = (1,2);
8473848f
RGS
640local *f, *g;
641no warnings 'parenthesis' ;
0453d815 642local $c, $d = (1,2);
599cee73 643EXPECT
df5b6949 644Parentheses missing around "local" list at - line 3.
8473848f 645Parentheses missing around "local" list at - line 4.
599cee73
PM
646########
647# op.c
e476b1b5 648use warnings 'bareword' ;
599cee73 649print (ABC || 1) ;
e476b1b5 650no warnings 'bareword' ;
0453d815 651print (ABC || 1) ;
599cee73 652EXPECT
34d09196 653Bareword found in conditional at - line 3.
599cee73
PM
654########
655--FILE-- abc
656
657--FILE--
658# op.c
e476b1b5 659use warnings 'misc' ;
599cee73
PM
660open FH, "<abc" ;
661$x = 1 if $x = <FH> ;
e476b1b5 662no warnings 'misc' ;
0453d815 663$x = 1 if $x = <FH> ;
599cee73
PM
664EXPECT
665Value of <HANDLE> construct can be "0"; test with defined() at - line 4.
666########
667# op.c
e476b1b5 668use warnings 'misc' ;
599cee73
PM
669opendir FH, "." ;
670$x = 1 if $x = readdir FH ;
e476b1b5 671no warnings 'misc' ;
0453d815 672$x = 1 if $x = readdir FH ;
599cee73
PM
673closedir FH ;
674EXPECT
675Value of readdir() operator can be "0"; test with defined() at - line 4.
676########
677# op.c
e476b1b5 678use warnings 'misc' ;
599cee73 679$x = 1 if $x = <*> ;
e476b1b5 680no warnings 'misc' ;
0453d815 681$x = 1 if $x = <*> ;
599cee73
PM
682EXPECT
683Value of glob construct can be "0"; test with defined() at - line 3.
684########
685# op.c
e476b1b5 686use warnings 'misc' ;
599cee73
PM
687%a = (1,2,3,4) ;
688$x = 1 if $x = each %a ;
e476b1b5 689no warnings 'misc' ;
0453d815 690$x = 1 if $x = each %a ;
599cee73
PM
691EXPECT
692Value of each() operator can be "0"; test with defined() at - line 4.
693########
694# op.c
e476b1b5 695use warnings 'misc' ;
599cee73 696$x = 1 while $x = <*> and 0 ;
e476b1b5 697no warnings 'misc' ;
0453d815 698$x = 1 while $x = <*> and 0 ;
599cee73
PM
699EXPECT
700Value of glob construct can be "0"; test with defined() at - line 3.
701########
702# op.c
e476b1b5 703use warnings 'misc' ;
599cee73
PM
704opendir FH, "." ;
705$x = 1 while $x = readdir FH and 0 ;
e476b1b5 706no warnings 'misc' ;
0453d815 707$x = 1 while $x = readdir FH and 0 ;
599cee73
PM
708closedir FH ;
709EXPECT
710Value of readdir() operator can be "0"; test with defined() at - line 4.
711########
712# op.c
59e10468
RGS
713use warnings 'misc';
714open FH, "<abc";
59e10468
RGS
715($_ = <FH>) // ($_ = 1);
716opendir DH, ".";
59e10468 717%a = (1,2,3,4) ;
59e10468
RGS
718EXPECT
719########
720# op.c
4438c4b7 721use warnings 'redefine' ;
599cee73
PM
722sub fred {}
723sub fred {}
4438c4b7 724no warnings 'redefine' ;
0453d815 725sub fred {}
599cee73
PM
726EXPECT
727Subroutine fred redefined at - line 4.
728########
729# op.c
4438c4b7 730use warnings 'redefine' ;
599cee73
PM
731sub fred () { 1 }
732sub fred () { 1 }
4438c4b7 733no warnings 'redefine' ;
0453d815 734sub fred () { 1 }
599cee73
PM
735EXPECT
736Constant subroutine fred redefined at - line 4.
737########
738# op.c
efcf35c4
FC
739sub fred () { 1 }
740sub fred () { 2 }
741EXPECT
742Constant subroutine fred redefined at - line 3.
743########
744# op.c
745sub fred () { 1 }
746*fred = sub () { 2 };
747EXPECT
748Constant subroutine main::fred redefined at - line 3.
749########
750# op.c
036b4402
GS
751no warnings 'redefine' ;
752sub fred () { 1 }
753sub fred () { 2 }
754EXPECT
036b4402
GS
755########
756# op.c
757no warnings 'redefine' ;
758sub fred () { 1 }
759*fred = sub () { 2 };
760EXPECT
036b4402
GS
761########
762# op.c
4438c4b7 763use warnings 'redefine' ;
599cee73
PM
764format FRED =
765.
766format FRED =
767.
4438c4b7 768no warnings 'redefine' ;
0453d815
PM
769format FRED =
770.
599cee73
PM
771EXPECT
772Format FRED redefined at - line 5.
773########
774# op.c
599cee73 775push FRED;
e476b1b5 776no warnings 'deprecated' ;
0453d815 777push FRED;
599cee73 778EXPECT
d1d15184 779Array @FRED missing the @ in argument 1 of push() at - line 2.
599cee73
PM
780########
781# op.c
599cee73 782@a = keys FRED ;
e476b1b5 783no warnings 'deprecated' ;
0453d815 784@a = keys FRED ;
599cee73 785EXPECT
d1d15184 786Hash %FRED missing the % in argument 1 of keys() at - line 2.
599cee73
PM
787########
788# op.c
4438c4b7 789use warnings 'syntax' ;
dfe13c55 790exec "$^X -e 1" ;
599cee73
PM
791my $a
792EXPECT
7b903762 793Statement unlikely to be reached at - line 4.
cc507455 794 (Maybe you meant system() when you said exec()?)
69794302 795########
ea31ed66
GG
796# op.c, no warning if exec isn't a statement.
797use warnings 'syntax' ;
798$a || exec "$^X -e 1" ;
799my $a
800EXPECT
801########
69794302 802# op.c
b880f709
NC
803defined(@a);
804EXPECT
805defined(@array) is deprecated at - line 2.
806 (Maybe you should just omit the defined()?)
807########
808# op.c
69794302
MJD
809my @a; defined(@a);
810EXPECT
d1d15184 811defined(@array) is deprecated at - line 2.
cc507455 812 (Maybe you should just omit the defined()?)
69794302
MJD
813########
814# op.c
69794302
MJD
815defined(@a = (1,2,3));
816EXPECT
d1d15184 817defined(@array) is deprecated at - line 2.
cc507455 818 (Maybe you should just omit the defined()?)
69794302
MJD
819########
820# op.c
b880f709
NC
821defined(%h);
822EXPECT
823defined(%hash) is deprecated at - line 2.
824 (Maybe you should just omit the defined()?)
825########
826# op.c
69794302
MJD
827my %h; defined(%h);
828EXPECT
d1d15184 829defined(%hash) is deprecated at - line 2.
cc507455 830 (Maybe you should just omit the defined()?)
0453d815
PM
831########
832# op.c
4438c4b7 833no warnings 'syntax' ;
0453d815
PM
834exec "$^X -e 1" ;
835my $a
836EXPECT
837
838########
839# op.c
840sub fred();
841sub fred($) {}
842EXPECT
843Prototype mismatch: sub main::fred () vs ($) at - line 3.
844########
845# op.c
dab1c735
BF
846use utf8;
847use open qw( :utf8 :std );
848sub frèd();
849sub frèd($) {}
850EXPECT
851Prototype mismatch: sub main::frèd () vs ($) at - line 5.
852########
853# op.c
854use utf8;
855use open qw( :utf8 :std );
856use warnings;
857eval "sub fòò (\$\0) {}";
858EXPECT
97eb901d 859Illegal character in prototype for main::fòò : $\0 at (eval 1) line 1.
dab1c735
BF
860########
861# op.c
862use utf8;
863use open qw( :utf8 :std );
864use warnings;
865eval "sub foo (\0) {}";
866EXPECT
97eb901d 867Illegal character in prototype for main::foo : \0 at (eval 1) line 1.
dab1c735
BF
868########
869# op.c
870use utf8;
871use open qw( :utf8 :std );
872use warnings;
873BEGIN { $::{"foo"} = "\$\0L\351on" }
874BEGIN { eval "sub foo (\$\0L\x{c3}\x{a9}on) {}"; }
875EXPECT
876Illegal character in prototype for main::foo : $\x{0}L... at (eval 1) line 1.
877########
878# op.c
879use utf8;
880use open qw( :utf8 :std );
881use warnings;
882BEGIN { eval "sub foo (\0) {}"; }
883EXPECT
97eb901d
BF
884Illegal character in prototype for main::foo : \0 at (eval 1) line 1.
885########
886# op.c
887use warnings;
888eval "sub foo (\xAB) {}";
889EXPECT
890Illegal character in prototype for main::foo : \x{ab} at (eval 1) line 1.
891########
892# op.c
893use utf8;
894use open qw( :utf8 :std );
895use warnings;
896BEGIN { eval "sub foo (\x{30cb}) {}"; }
897EXPECT
898Illegal character in prototype for main::foo : \x{30cb} at (eval 1) line 1.
dab1c735
BF
899########
900# op.c
901use utf8;
902use open qw( :utf8 :std );
903use warnings;
904BEGIN { $::{"foo"} = "\x{30cb}" }
905BEGIN { eval "sub foo {}"; }
906EXPECT
907Prototype mismatch: sub main::foo (ニ) vs none at (eval 1) line 1.
908########
909# op.c
0453d815
PM
910$^W = 0 ;
911sub fred() ;
912sub fred($) {}
913{
e476b1b5 914 no warnings 'prototype' ;
0453d815
PM
915 sub Fred() ;
916 sub Fred($) {}
e476b1b5 917 use warnings 'prototype' ;
0453d815
PM
918 sub freD() ;
919 sub freD($) {}
920}
921sub FRED() ;
922sub FRED($) {}
923EXPECT
924Prototype mismatch: sub main::fred () vs ($) at - line 4.
925Prototype mismatch: sub main::freD () vs ($) at - line 11.
926Prototype mismatch: sub main::FRED () vs ($) at - line 14.
eb6e2d6f 927########
89474f50
FC
928# op.c [Perl_ck_cmp]
929use warnings 'syntax' ;
930no warnings 'deprecated';
931@a = $[ < 5;
932@a = $[ > 5;
933@a = $[ <= 5;
934@a = $[ >= 5;
935@a = 42 < $[;
936@a = 42 > $[;
937@a = 42 <= $[;
938@a = 42 >= $[;
939use integer;
940@a = $[ < 5;
941@a = $[ > 5;
942@a = $[ <= 5;
943@a = $[ >= 5;
944@a = 42 < $[;
945@a = 42 > $[;
946@a = 42 <= $[;
947@a = 42 >= $[;
7c2b3c78
FC
948no integer;
949@a = $[ < $5;
950@a = $[ > $5;
951@a = $[ <= $5;
952@a = $[ >= $5;
953@a = $42 < $[;
954@a = $42 > $[;
955@a = $42 <= $[;
956@a = $42 >= $[;
957use integer;
958@a = $[ < $5;
959@a = $[ > $5;
960@a = $[ <= $5;
961@a = $[ >= $5;
962@a = $42 < $[;
963@a = $42 > $[;
964@a = $42 <= $[;
965@a = $42 >= $[;
89474f50
FC
966EXPECT
967$[ used in numeric lt (<) (did you mean $] ?) at - line 4.
968$[ used in numeric gt (>) (did you mean $] ?) at - line 5.
969$[ used in numeric le (<=) (did you mean $] ?) at - line 6.
970$[ used in numeric ge (>=) (did you mean $] ?) at - line 7.
971$[ used in numeric lt (<) (did you mean $] ?) at - line 8.
972$[ used in numeric gt (>) (did you mean $] ?) at - line 9.
973$[ used in numeric le (<=) (did you mean $] ?) at - line 10.
974$[ used in numeric ge (>=) (did you mean $] ?) at - line 11.
975$[ used in numeric lt (<) (did you mean $] ?) at - line 13.
976$[ used in numeric gt (>) (did you mean $] ?) at - line 14.
977$[ used in numeric le (<=) (did you mean $] ?) at - line 15.
978$[ used in numeric ge (>=) (did you mean $] ?) at - line 16.
979$[ used in numeric lt (<) (did you mean $] ?) at - line 17.
980$[ used in numeric gt (>) (did you mean $] ?) at - line 18.
981$[ used in numeric le (<=) (did you mean $] ?) at - line 19.
982$[ used in numeric ge (>=) (did you mean $] ?) at - line 20.
983########
e508c8a4
MH
984# op.c [Perl_ck_length]
985use warnings 'syntax' ;
986length(@a);
579333ee
FC
987length(%b);
988length(@$c);
989length(%$d);
e508c8a4 990length($a);
9710ad41 991length(my %h);
579333ee 992length(my @g);
e508c8a4 993EXPECT
579333ee
FC
994length() used on @a (did you mean "scalar(@a)"?) at - line 3.
995length() used on %b (did you mean "scalar(keys %b)"?) at - line 4.
e508c8a4
MH
996length() used on @array (did you mean "scalar(@array)"?) at - line 5.
997length() used on %hash (did you mean "scalar(keys %hash)"?) at - line 6.
579333ee
FC
998length() used on %h (did you mean "scalar(keys %h)"?) at - line 8.
999length() used on @g (did you mean "scalar(@g)"?) at - line 9.
e508c8a4 1000########
eb6e2d6f
GS
1001# op.c
1002use warnings 'syntax' ;
1003join /---/, 'x', 'y', 'z';
1004EXPECT
1005/---/ should probably be written as "---" at - line 3.
767a6a26 1006########
ce16c625
BF
1007# op.c
1008use utf8;
1009use open qw( :utf8 :std );
1010use warnings 'syntax' ;
1011join /~~~/, 'x', 'y', 'z';
1012EXPECT
1013/~~~/ should probably be written as "~~~" at - line 5.
1014########
767a6a26 1015# op.c [Perl_peep]
e476b1b5 1016use warnings 'prototype' ;
767a6a26
PM
1017fred() ;
1018sub fred ($$) {}
e476b1b5 1019no warnings 'prototype' ;
767a6a26
PM
1020joe() ;
1021sub joe ($$) {}
1022EXPECT
1023main::fred() called too early to check prototype at - line 3.
ddda08b7
GS
1024########
1025# op.c [Perl_newATTRSUB]
1026--FILE-- abc.pm
1027use warnings 'void' ;
1028BEGIN { $| = 1; print "in begin\n"; }
1029CHECK { print "in check\n"; }
1030INIT { print "in init\n"; }
1031END { print "in end\n"; }
1032print "in mainline\n";
10331;
1034--FILE--
1035use abc;
1036delete $INC{"abc.pm"};
1037require abc;
1038do "abc.pm";
1039EXPECT
1040in begin
1041in mainline
1042in check
1043in init
1044in begin
1045Too late to run CHECK block at abc.pm line 3.
1046Too late to run INIT block at abc.pm line 4.
1047in mainline
1048in begin
1049Too late to run CHECK block at abc.pm line 3.
1050Too late to run INIT block at abc.pm line 4.
1051in mainline
1052in end
1053in end
1054in end
1055########
1056# op.c [Perl_newATTRSUB]
1057--FILE-- abc.pm
1058no warnings 'void' ;
1059BEGIN { $| = 1; print "in begin\n"; }
1060CHECK { print "in check\n"; }
1061INIT { print "in init\n"; }
1062END { print "in end\n"; }
1063print "in mainline\n";
10641;
1065--FILE--
1066require abc;
1067do "abc.pm";
1068EXPECT
1069in begin
1070in mainline
1071in begin
1072in mainline
1073in end
1074in end
936edb8b
RH
1075########
1076# op.c
1077my @x;
f87c3213 1078use warnings 'syntax' ;
936edb8b
RH
1079push(@x);
1080unshift(@x);
f87c3213 1081no warnings 'syntax' ;
936edb8b
RH
1082push(@x);
1083unshift(@x);
1084EXPECT
de4864e4
JH
1085Useless use of push with no values at - line 4.
1086Useless use of unshift with no values at - line 5.
a27978d3
AMS
1087########
1088# op.c
f34840d8
MJD
1089# 20020401 mjd@plover.com at suggestion of jfriedl@yahoo.com
1090use warnings 'regexp';
1091split /blah/g, "blah";
1092no warnings 'regexp';
1093split /blah/g, "blah";
1094EXPECT
1095Use of /g modifier is meaningless in split at - line 4.
276b2a0c
RGS
1096########
1097# op.c
1098use warnings 'precedence';
1099$a = $b & $c == $d;
1100$a = $b ^ $c != $d;
1101$a = $b | $c > $d;
1102$a = $b < $c & $d;
1103$a = $b >= $c ^ $d;
1104$a = $b <= $c | $d;
1105$a = $b <=> $c & $d;
2b84528b 1106$a &= $b == $c; $a |= $b == $c; $a ^= $b == $c; # shouldn't warn
276b2a0c
RGS
1107no warnings 'precedence';
1108$a = $b & $c == $d;
1109$a = $b ^ $c != $d;
1110$a = $b | $c > $d;
1111$a = $b < $c & $d;
1112$a = $b >= $c ^ $d;
1113$a = $b <= $c | $d;
1114$a = $b <=> $c & $d;
1115EXPECT
1116Possible precedence problem on bitwise & operator at - line 3.
1117Possible precedence problem on bitwise ^ operator at - line 4.
1118Possible precedence problem on bitwise | operator at - line 5.
1119Possible precedence problem on bitwise & operator at - line 6.
1120Possible precedence problem on bitwise ^ operator at - line 7.
1121Possible precedence problem on bitwise | operator at - line 8.
1122Possible precedence problem on bitwise & operator at - line 9.
1123########
1124# op.c
1125use integer;
1126use warnings 'precedence';
1127$a = $b & $c == $d;
1128$a = $b ^ $c != $d;
1129$a = $b | $c > $d;
1130$a = $b < $c & $d;
1131$a = $b >= $c ^ $d;
1132$a = $b <= $c | $d;
1133$a = $b <=> $c & $d;
1134no warnings 'precedence';
1135$a = $b & $c == $d;
1136$a = $b ^ $c != $d;
1137$a = $b | $c > $d;
1138$a = $b < $c & $d;
1139$a = $b >= $c ^ $d;
1140$a = $b <= $c | $d;
1141$a = $b <=> $c & $d;
1142EXPECT
1143Possible precedence problem on bitwise & operator at - line 4.
1144Possible precedence problem on bitwise ^ operator at - line 5.
1145Possible precedence problem on bitwise | operator at - line 6.
1146Possible precedence problem on bitwise & operator at - line 7.
1147Possible precedence problem on bitwise ^ operator at - line 8.
1148Possible precedence problem on bitwise | operator at - line 9.
1149Possible precedence problem on bitwise & operator at - line 10.
ddeae0f1
DM
1150########
1151# op.c
1152
1153# ok => local() has desired effect;
1154# ignore=> local() silently ignored
1155
1156use warnings 'syntax';
1157
1158local(undef); # OP_UNDEF ignore
1159sub lval : lvalue {};
1160local(lval()); # OP_ENTERSUB
1161local($x **= 1); # OP_POW
1162local($x *= 1); # OP_MULTIPLY
1163local($x /= 1); # OP_DIVIDE
1164local($x %= 1); # OP_MODULO
1165local($x x= 1); # OP_REPEAT
1166local($x += 1); # OP_ADD
1167local($x -= 1); # OP_SUBTRACT
1168local($x .= 1); # OP_CONCAT
1169local($x <<= 1); # OP_LEFT_SHIFT
1170local($x >>= 1); # OP_RIGHT_SHIFT
1171local($x &= 1); # OP_BIT_AND
1172local($x ^= 1); # OP_BIT_XOR
1173local($x |= 1); # OP_BIT_OR
1174{
1175 use integer;
1176 local($x *= 1); # OP_I_MULTIPLY
1177 local($x /= 1); # OP_I_DIVIDE
1178 local($x %= 1); # OP_I_MODULO
1179 local($x += 1); # OP_I_ADD
1180 local($x -= 1); # OP_I_SUBTRACT
1181}
1182local($x?$y:$z) = 1; # OP_COND_EXPR ok
1183# these two are fatal run-time errors instead
1184#local(@$a); # OP_RV2AV ok
1185#local(%$a); # OP_RV2HV ok
1186local(*a); # OP_RV2GV ok
1187local(@a[1,2]); # OP_ASLICE ok
1188local(@a{1,2}); # OP_HSLICE ok
1189local(@a = (1,2)); # OP_AASSIGN
1190local($$x); # OP_RV2SV ok
1191local($#a); # OP_AV2ARYLEN
1192local($x = 1); # OP_SASSIGN
1193local($x &&= 1); # OP_ANDASSIGN
1194local($x ||= 1); # OP_ORASSIGN
1195local($x //= 1); # OP_DORASSIGN
1196local($a[0]); # OP_AELEMFAST ok
1197
1198local(substr($x,0,1)); # OP_SUBSTR
1199local(pos($x)); # OP_POS
1200local(vec($x,0,1)); # OP_VEC
1201local($a[$b]); # OP_AELEM ok
1202local($a{$b}); # OP_HELEM ok
1203
1204no warnings 'syntax';
1205EXPECT
1206Useless localization of subroutine entry at - line 10.
1207Useless localization of exponentiation (**) at - line 11.
1208Useless localization of multiplication (*) at - line 12.
1209Useless localization of division (/) at - line 13.
1210Useless localization of modulus (%) at - line 14.
1211Useless localization of repeat (x) at - line 15.
1212Useless localization of addition (+) at - line 16.
1213Useless localization of subtraction (-) at - line 17.
1214Useless localization of concatenation (.) or string at - line 18.
1215Useless localization of left bitshift (<<) at - line 19.
1216Useless localization of right bitshift (>>) at - line 20.
1217Useless localization of bitwise and (&) at - line 21.
1218Useless localization of bitwise xor (^) at - line 22.
1219Useless localization of bitwise or (|) at - line 23.
1220Useless localization of integer multiplication (*) at - line 26.
1221Useless localization of integer division (/) at - line 27.
1222Useless localization of integer modulus (%) at - line 28.
1223Useless localization of integer addition (+) at - line 29.
1224Useless localization of integer subtraction (-) at - line 30.
1225Useless localization of list assignment at - line 39.
1226Useless localization of array length at - line 41.
1227Useless localization of scalar assignment at - line 42.
1228Useless localization of logical and assignment (&&=) at - line 43.
1229Useless localization of logical or assignment (||=) at - line 44.
1230Useless localization of defined or assignment (//=) at - line 45.
1231Useless localization of substr at - line 48.
1232Useless localization of match position at - line 49.
1233Useless localization of vec at - line 50.
7921d0f2
DM
1234########
1235# op.c
7921d0f2
DM
1236my $x1 if 0;
1237my @x2 if 0;
1238my %x3 if 0;
1239my ($x4) if 0;
1240my ($x5,@x6, %x7) if 0;
12410 && my $z1;
12420 && my (%z2);
1243# these shouldn't warn
1244our $x if 0;
1245our $x unless 0;
1246if (0) { my $w1 }
1247if (my $w2) { $a=1 }
1248if ($a && (my $w3 = 1)) {$a = 2}
1249
1250EXPECT
d1d15184 1251Deprecated use of my() in false conditional at - line 2.
7921d0f2
DM
1252Deprecated use of my() in false conditional at - line 3.
1253Deprecated use of my() in false conditional at - line 4.
1254Deprecated use of my() in false conditional at - line 5.
1255Deprecated use of my() in false conditional at - line 6.
1256Deprecated use of my() in false conditional at - line 7.
1257Deprecated use of my() in false conditional at - line 8.
55b67815
RGS
1258########
1259# op.c
36b2db7e
FC
1260$[ = 1;
1261($[) = 1;
1262use warnings 'deprecated';
1263$[ = 2;
1264($[) = 2;
1265no warnings 'deprecated';
1266$[ = 3;
1267($[) = 3;
1268EXPECT
1269Use of assignment to $[ is deprecated at - line 2.
1270Use of assignment to $[ is deprecated at - line 3.
1271Use of assignment to $[ is deprecated at - line 5.
1272Use of assignment to $[ is deprecated at - line 6.
1273########
1274# op.c
75068674
RGS
1275use warnings 'void';
1276@x = split /y/, "z";
1277$x = split /y/, "z";
1278 split /y/, "z";
1279no warnings 'void';
1280@x = split /y/, "z";
1281$x = split /y/, "z";
1282 split /y/, "z";
1283EXPECT
1284Useless use of split in void context at - line 5.
34ee6772
BF
1285########
1286# op.c
1287use warnings 'redefine' ;
1288use utf8;
1289use open qw( :utf8 :std );
1290sub frèd {}
1291sub frèd {}
1292no warnings 'redefine' ;
1293sub frèd {}
1294EXPECT
1295Subroutine frèd redefined at - line 6.
1296########
1297# op.c
1298use warnings 'redefine' ;
1299use utf8;
1300use open qw( :utf8 :std );
1301sub frèd () { 1 }
1302sub frèd () { 1 }
1303no warnings 'redefine' ;
1304sub frèd () { 1 }
1305EXPECT
1306Constant subroutine frèd redefined at - line 6.
1307########
1308# op.c
34ee6772
BF
1309use utf8;
1310use open qw( :utf8 :std );
1311sub frèd () { 1 }
1312sub frèd () { 2 }
1313EXPECT
efcf35c4 1314Constant subroutine frèd redefined at - line 5.
34ee6772
BF
1315########
1316# op.c
34ee6772
BF
1317use utf8;
1318use open qw( :utf8 :std );
1319sub frèd () { 1 }
1320*frèd = sub () { 2 };
1321EXPECT
efcf35c4 1322Constant subroutine main::frèd redefined at - line 5.
34ee6772
BF
1323########
1324# op.c
1325use warnings 'redefine' ;
1326use utf8;
1327use open qw( :utf8 :std );
1328sub ᚠርƊ {}
1329sub ᚠርƊ {}
1330no warnings 'redefine' ;
1331sub ᚠርƊ {}
1332EXPECT
1333Subroutine ᚠርƊ redefined at - line 6.
1334########
1335# op.c
1336use warnings 'redefine' ;
1337use utf8;
1338use open qw( :utf8 :std );
1339sub ᚠርƊ () { 1 }
1340sub ᚠርƊ () { 1 }
1341no warnings 'redefine' ;
1342sub ᚠርƊ () { 1 }
1343EXPECT
1344Constant subroutine ᚠርƊ redefined at - line 6.
1345########
1346# op.c
34ee6772
BF
1347use utf8;
1348use open qw( :utf8 :std );
1349sub ᚠርƊ () { 1 }
1350sub ᚠርƊ () { 2 }
1351EXPECT
efcf35c4 1352Constant subroutine ᚠርƊ redefined at - line 5.
34ee6772
BF
1353########
1354# op.c
34ee6772
BF
1355use utf8;
1356use open qw( :utf8 :std );
1357sub ᚠርƊ () { 1 }
1358*ᚠርƊ = sub () { 2 };
1359EXPECT
efcf35c4 1360Constant subroutine main::ᚠርƊ redefined at - line 5.
34ee6772 1361########