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