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