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