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