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