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