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