1toke.c AOK 2 3 we seem to have lost a few ambiguous warnings!! 4 5 6 $a = <<; 7 Use of comma-less variable list is deprecated 8 (called 3 times via depcom) 9 10 \1 better written as $1 11 use warnings 'syntax' ; 12 s/(abc)/\1/; 13 14 warn(warn_nosemi) 15 Semicolon seems to be missing 16 $a = 1 17 &time ; 18 19 20 Reversed %c= operator 21 my $a =+ 2 ; 22 $a =- 2 ; 23 $a =* 2 ; 24 $a =% 2 ; 25 $a =& 2 ; 26 $a =. 2 ; 27 $a =^ 2 ; 28 $a =| 2 ; 29 $a =< 2 ; 30 $a =/ 2 ; 31 32 Multidimensional syntax %.*s not supported 33 my $a = $a[1,2] ; 34 35 You need to quote \"%s\"" 36 sub fred {} ; $SIG{TERM} = fred; 37 38 Can't use \\%c to mean $%c in expression 39 $_ = "ab" ; s/(ab)/\1/e; 40 41 Unquoted string "abc" may clash with future reserved word at - line 3. 42 warn(warn_reserved 43 $a = abc; 44 45 Possible attempt to separate words with commas 46 @a = qw(a, b, c) ; 47 48 Possible attempt to put comments in qw() list 49 @a = qw(a b # c) ; 50 51 %s (...) interpreted as function 52 print ("") 53 printf ("") 54 sort ("") 55 56 Ambiguous use of %c{%s%s} resolved to %c%s%s 57 $a = ${time[2]} 58 $a = ${time{2}} 59 60 61 Ambiguous use of %c{%s} resolved to %c%s 62 $a = ${time} 63 sub fred {} $a = ${fred} 64 65 Misplaced _ in number 66 $a = 1_2; 67 $a = 1_2345_6; 68 69 Bareword \"%s\" refers to nonexistent package 70 $a = FRED:: ; 71 72 Ambiguous call resolved as CORE::%s(), qualify as such or use & 73 sub time {} 74 my $a = time() 75 76 Unrecognized escape \\%c passed through 77 $a = "\m" ; 78 79 Useless use of \\E. 80 $a = "abcd\E" ; 81 82 Postfix dereference is experimental 83 84 %s number > %s non-portable 85 my $a = 0b011111111111111111111111111111110 ; 86 $a = 0b011111111111111111111111111111111 ; 87 $a = 0b111111111111111111111111111111111 ; 88 $a = 0x0fffffffe ; 89 $a = 0x0ffffffff ; 90 $a = 0x1ffffffff ; 91 $a = 0037777777776 ; 92 $a = 0037777777777 ; 93 $a = 0047777777777 ; 94 95 Integer overflow in binary number 96 my $a = 0b011111111111111111111111111111110 ; 97 $a = 0b011111111111111111111111111111111 ; 98 $a = 0b111111111111111111111111111111111 ; 99 $a = 0x0fffffffe ; 100 $a = 0x0ffffffff ; 101 $a = 0x1ffffffff ; 102 $a = 0037777777776 ; 103 $a = 0037777777777 ; 104 $a = 0047777777777 ; 105 106 dump() better written as CORE::dump() 107 108 Use of /c modifier is meaningless without /g 109 110 Use of /c modifier is meaningless in s/// 111 112 Mandatory Warnings 113 ------------------ 114 Use of "%s" without parentheses is ambiguous [check_uni] 115 rand + 4 116 117 Ambiguous use of -%s resolved as -&%s() [yylex] 118 sub fred {} ; - fred ; 119 120 Precedence problem: open %.*s should be open(%.*s) [yylex] 121 open FOO || die; 122 123 Operator or semicolon missing before %c%s [yylex] 124 Ambiguous use of %c resolved as operator %c 125 *foo *foo 126 127__END__ 128# toke.c 129format STDOUT = 130@<<< @||| @>>> @>>> 131$a $b "abc" 'def' 132. 133no warnings 'deprecated' ; 134format STDOUT = 135@<<< @||| @>>> @>>> 136$a $b "abc" 'def' 137. 138EXPECT 139Use of comma-less variable list is deprecated at - line 4. 140Use of comma-less variable list is deprecated at - line 4. 141Use of comma-less variable list is deprecated at - line 4. 142######## 143# toke.c 144$a = <<; 145 146no warnings 'deprecated' ; 147$a = <<; 148 149EXPECT 150Use of bare << to mean <<"" is deprecated at - line 2. 151######## 152# toke.c 153$a =~ m/$foo/eq; 154$a =~ s/$foo/fool/seq; 155 156EXPECT 157OPTION fatal 158Unknown regexp modifier "/e" at - line 2, near "=~ " 159Unknown regexp modifier "/q" at - line 2, near "=~ " 160Unknown regexp modifier "/q" at - line 3, near "=~ " 161Execution of - aborted due to compilation errors. 162######## 163# toke.c 164use utf8; 165use open qw( :utf8 :std ); 166$a =~ m/$foo/eネq; 167$a =~ s/$foo/fool/seネq; 168 169EXPECT 170OPTION fatal 171Unknown regexp modifier "/e" at - line 4, near "=~ " 172Unknown regexp modifier "/ネ" at - line 4, near "=~ " 173Unknown regexp modifier "/q" at - line 4, near "=~ " 174Unknown regexp modifier "/ネ" at - line 5, near "=~ " 175Unknown regexp modifier "/q" at - line 5, near "=~ " 176Execution of - aborted due to compilation errors. 177######## 178# toke.c 179use warnings 'syntax' ; 180s/(abc)/\1/; 181no warnings 'syntax' ; 182s/(abc)/\1/; 183EXPECT 184\1 better written as $1 at - line 3. 185######## 186# toke.c 187use warnings 'semicolon' ; 188$a = 1 189&time ; 190no warnings 'semicolon' ; 191$a = 1 192&time ; 193EXPECT 194Semicolon seems to be missing at - line 3. 195######## 196# toke.c 197use warnings 'syntax' ; 198my $a =+ 2 ; 199$a =- 2 ; 200$a =* 2 ; 201$a =% 2 ; 202$a =& 2 ; 203$a =. 2 ; 204$a =^ 2 ; 205$a =| 2 ; 206$a =< 2 ; 207$a =/ 2 ; 208EXPECT 209Reversed += operator at - line 3. 210Reversed -= operator at - line 4. 211Reversed *= operator at - line 5. 212Reversed %= operator at - line 6. 213Reversed &= operator at - line 7. 214Reversed .= operator at - line 8. 215Reversed ^= operator at - line 9. 216Reversed |= operator at - line 10. 217Reversed <= operator at - line 11. 218syntax error at - line 8, near "=." 219syntax error at - line 9, near "=^" 220syntax error at - line 10, near "=|" 221Unterminated <> operator at - line 11. 222######## 223# toke.c 224no warnings 'syntax' ; 225my $a =+ 2 ; 226$a =- 2 ; 227$a =* 2 ; 228$a =% 2 ; 229$a =& 2 ; 230$a =. 2 ; 231$a =^ 2 ; 232$a =| 2 ; 233$a =< 2 ; 234$a =/ 2 ; 235EXPECT 236syntax error at - line 8, near "=." 237syntax error at - line 9, near "=^" 238syntax error at - line 10, near "=|" 239Unterminated <> operator at - line 11. 240######## 241# toke.c 242use warnings 'syntax' ; 243my $a = $a[1,2] ; 244no warnings 'syntax' ; 245my $a = $a[1,2] ; 246EXPECT 247Multidimensional syntax $a[1,2] not supported at - line 3. 248######## 249# toke.c 250use warnings 'syntax' ; 251sub fred {} ; $SIG{TERM} = fred; 252no warnings 'syntax' ; 253$SIG{TERM} = fred; 254EXPECT 255You need to quote "fred" at - line 3. 256######## 257# toke.c 258use utf8; 259use open qw( :utf8 :std ); 260use warnings 'syntax' ; 261sub frèd {} ; $SIG{TERM} = frèd; 262no warnings 'syntax' ; 263$SIG{TERM} = frèd; 264EXPECT 265You need to quote "frèd" at - line 5. 266######## 267# toke.c 268use utf8; 269use open qw( :utf8 :std ); 270use warnings 'syntax' ; 271sub ふれど {} ; $SIG{TERM} = ふれど; 272no warnings 'syntax' ; 273$SIG{TERM} = ふれど; 274EXPECT 275You need to quote "ふれど" at - line 5. 276######## 277# toke.c 278use warnings 'syntax' ; 279$_ = "ab" ; 280s/(ab)/\1/e; 281s//\(2)/e; # should be exempt 282s/${\2}//; # same here 283()="${\2}"; # metoo 284no warnings 'syntax' ; 285$_ = "ab" ; 286s/(ab)/\1/e; 287EXPECT 288Can't use \1 to mean $1 in expression at - line 4. 289######## 290# toke.c 291use warnings 'reserved' ; 292$a = abc; 293$a = { def 294 295=> 1 }; 296no warnings 'reserved' ; 297$a = abc; 298EXPECT 299Unquoted string "abc" may clash with future reserved word at - line 3. 300######## 301# toke.c 302use warnings 'qw' ; 303@a = qw(a, b, c) ; 304no warnings 'qw' ; 305@a = qw(a, b, c) ; 306EXPECT 307Possible attempt to separate words with commas at - line 3. 308######## 309# toke.c 310use warnings 'qw' ; 311@a = qw(a b c # #) ; 312no warnings 'qw' ; 313@a = qw(a b c # #) ; 314EXPECT 315Possible attempt to put comments in qw() list at - line 3. 316######## 317# toke.c 318use warnings 'qw' ; 319@a = qw(a, b, c # #) ; 320no warnings 'qw' ; 321@a = qw(a, b, c # #) ; 322EXPECT 323Possible attempt to separate words with commas at - line 3. 324Possible attempt to put comments in qw() list at - line 3. 325######## 326# toke.c 327use warnings 'syntax' ; 328print (""); 329print ("") and $x = 1; 330print ("") or die; 331print ("") // die; 332print (1+2) * 3 if 0; # only this one should warn 333print (1+2) if 0; 334EXPECT 335print (...) interpreted as function at - line 7. 336######## 337# toke.c 338no warnings 'syntax' ; 339print ("") 340EXPECT 341 342######## 343# toke.c 344use warnings 'syntax' ; 345printf (""); 346printf ("") . ''; 347EXPECT 348printf (...) interpreted as function at - line 4. 349######## 350# toke.c 351no warnings 'syntax' ; 352printf ("") 353EXPECT 354 355######## 356# toke.c 357use warnings 'syntax' ; 358sort (""); 359sort ("") . ''; 360EXPECT 361sort (...) interpreted as function at - line 4. 362######## 363# toke.c 364no warnings 'syntax' ; 365sort ("") 366EXPECT 367 368######## 369# toke.c 370use warnings 'ambiguous' ; 371$a = ${time[2]}; 372no warnings 'ambiguous' ; 373$a = ${time[2]}; 374EXPECT 375Ambiguous use of ${time[...]} resolved to $time[...] at - line 3. 376######## 377# toke.c 378use warnings 'ambiguous' ; 379$a = ${time{2}}; 380EXPECT 381Ambiguous use of ${time{...}} resolved to $time{...} at - line 3. 382######## 383# toke.c 384use warnings 'ambiguous' ; 385$a = ${ 386 387 time 388 {2} 389}; 390warn "after"; 391EXPECT 392Ambiguous use of ${time{...}} resolved to $time{...} at - line 5. 393after at - line 8. 394######## 395# toke.c 396use warnings 'ambiguous' ; 397$a = ${ 398 399time[2] 400 401}; 402$a = ${ 403 404time 405 [2] 406 407}; 408warn "after"; 409EXPECT 410Ambiguous use of ${time[...]} resolved to $time[...] at - line 5. 411Ambiguous use of ${time[...]} resolved to $time[...] at - line 10. 412after at - line 14. 413######## 414# toke.c 415no warnings 'ambiguous' ; 416$a = ${time{2}}; 417EXPECT 418 419######## 420# toke.c 421use warnings 'ambiguous' ; 422$a = ${time} ; 423$a = @{time} ; 424$a = $#{time} ; # This one is special cased in toke.c 425$a = %{time} ; 426$a = *{time} ; 427$a = defined &{time} ; # To avoid calling &::time 428no warnings 'ambiguous' ; 429$a = ${time} ; 430$a = @{time} ; 431$a = $#{time} ; # This one is special cased in toke.c 432$a = %{time} ; 433$a = *{time} ; 434$a = defined &{time} ; # To avoid calling &::time 435EXPECT 436Ambiguous use of ${time} resolved to $time at - line 3. 437Ambiguous use of @{time} resolved to @time at - line 4. 438Ambiguous use of @{time} resolved to @time at - line 5. 439Ambiguous use of %{time} resolved to %time at - line 6. 440Ambiguous use of *{time} resolved to *time at - line 7. 441Ambiguous use of &{time} resolved to &time at - line 8. 442######## 443# toke.c 444use warnings 'ambiguous' ; 445$a = ${ 446time 447} ; 448$a = @{ 449time 450} ; 451$a = $#{ 452time 453} ; 454$a = %{ 455time 456} ; 457$a = *{ 458time 459} ; 460$a = defined &{ 461time 462 463 464} ; 465warn "last"; 466EXPECT 467Ambiguous use of ${time} resolved to $time at - line 4. 468Ambiguous use of @{time} resolved to @time at - line 7. 469Ambiguous use of @{time} resolved to @time at - line 10. 470Ambiguous use of %{time} resolved to %time at - line 13. 471Ambiguous use of *{time} resolved to *time at - line 16. 472Ambiguous use of &{time} resolved to &time at - line 19. 473last at - line 23. 474######## 475# toke.c 476use warnings 'ambiguous' ; 477sub fred {} 478$a = ${fred} ; 479no warnings 'ambiguous' ; 480$a = ${fred} ; 481EXPECT 482Ambiguous use of ${fred} resolved to $fred at - line 4. 483######## 484# toke.c 485use warnings 'syntax' ; 486$a = _123; print "$a\n"; #( 3 string) 487$a = 1_23; print "$a\n"; 488$a = 12_3; print "$a\n"; 489$a = 123_; print "$a\n"; # 6 490$a = _+123; print "$a\n"; # 7 string) 491$a = +_123; print "$a\n"; #( 8 string) 492$a = +1_23; print "$a\n"; 493$a = +12_3; print "$a\n"; 494$a = +123_; print "$a\n"; # 11 495$a = _-123; print "$a\n"; #(12 string) 496$a = -_123; print "$a\n"; #(13 string) 497$a = -1_23; print "$a\n"; 498$a = -12_3; print "$a\n"; 499$a = -123_; print "$a\n"; # 16 500$a = 123._456; print "$a\n"; # 17 501$a = 123.4_56; print "$a\n"; 502$a = 123.45_6; print "$a\n"; 503$a = 123.456_; print "$a\n"; # 20 504$a = +123._456; print "$a\n"; # 21 505$a = +123.4_56; print "$a\n"; 506$a = +123.45_6; print "$a\n"; 507$a = +123.456_; print "$a\n"; # 24 508$a = -123._456; print "$a\n"; # 25 509$a = -123.4_56; print "$a\n"; 510$a = -123.45_6; print "$a\n"; 511$a = -123.456_; print "$a\n"; # 28 512$a = 123.456E_12; printf("%.0f\n", $a); # 29 513$a = 123.456E1_2; printf("%.0f\n", $a); 514$a = 123.456E12_; printf("%.0f\n", $a); # 31 515$a = 123.456E_+12; printf("%.0f\n", $a); # 32 516$a = 123.456E+_12; printf("%.0f\n", $a); # 33 517$a = 123.456E+1_2; printf("%.0f\n", $a); 518$a = 123.456E+12_; printf("%.0f\n", $a); # 35 519$a = 123.456E_-12; print "$a\n"; # 36 520$a = 123.456E-_12; print "$a\n"; # 37 521$a = 123.456E-1_2; print "$a\n"; 522$a = 123.456E-12_; print "$a\n"; # 39 523$a = 1__23; print "$a\n"; # 40 524$a = 12.3__4; print "$a\n"; # 41 525$a = 12.34e1__2; printf("%.0f\n", $a); # 42 526no warnings 'syntax' ; 527$a = _123; print "$a\n"; 528$a = 1_23; print "$a\n"; 529$a = 12_3; print "$a\n"; 530$a = 123_; print "$a\n"; 531$a = _+123; print "$a\n"; 532$a = +_123; print "$a\n"; 533$a = +1_23; print "$a\n"; 534$a = +12_3; print "$a\n"; 535$a = +123_; print "$a\n"; 536$a = _-123; print "$a\n"; 537$a = -_123; print "$a\n"; 538$a = -1_23; print "$a\n"; 539$a = -12_3; print "$a\n"; 540$a = -123_; print "$a\n"; 541$a = 123._456; print "$a\n"; 542$a = 123.4_56; print "$a\n"; 543$a = 123.45_6; print "$a\n"; 544$a = 123.456_; print "$a\n"; 545$a = +123._456; print "$a\n"; 546$a = +123.4_56; print "$a\n"; 547$a = +123.45_6; print "$a\n"; 548$a = +123.456_; print "$a\n"; 549$a = -123._456; print "$a\n"; 550$a = -123.4_56; print "$a\n"; 551$a = -123.45_6; print "$a\n"; 552$a = -123.456_; print "$a\n"; 553$a = 123.456E_12; printf("%.0f\n", $a); 554$a = 123.456E1_2; printf("%.0f\n", $a); 555$a = 123.456E12_; printf("%.0f\n", $a); 556$a = 123.456E_+12; printf("%.0f\n", $a); 557$a = 123.456E+_12; printf("%.0f\n", $a); 558$a = 123.456E+1_2; printf("%.0f\n", $a); 559$a = 123.456E+12_; printf("%.0f\n", $a); 560$a = 123.456E_-12; print "$a\n"; 561$a = 123.456E-_12; print "$a\n"; 562$a = 123.456E-1_2; print "$a\n"; 563$a = 123.456E-12_; print "$a\n"; 564$a = 1__23; print "$a\n"; 565$a = 12.3__4; print "$a\n"; 566$a = 12.34e1__2; printf("%.0f\n", $a); 567EXPECT 568OPTIONS regex 569Misplaced _ in number at - line 6. 570Misplaced _ in number at - line 11. 571Misplaced _ in number at - line 16. 572Misplaced _ in number at - line 17. 573Misplaced _ in number at - line 20. 574Misplaced _ in number at - line 21. 575Misplaced _ in number at - line 24. 576Misplaced _ in number at - line 25. 577Misplaced _ in number at - line 28. 578Misplaced _ in number at - line 29. 579Misplaced _ in number at - line 31. 580Misplaced _ in number at - line 32. 581Misplaced _ in number at - line 33. 582Misplaced _ in number at - line 35. 583Misplaced _ in number at - line 36. 584Misplaced _ in number at - line 37. 585Misplaced _ in number at - line 39. 586Misplaced _ in number at - line 40. 587Misplaced _ in number at - line 41. 588Misplaced _ in number at - line 42. 589_123 590123 591123 592123 593123 594_123 595123 596123 597123 598-123 599-_123 600-123 601-123 602-123 603123.456 604123.456 605123.456 606123.456 607123.456 608123.456 609123.456 610123.456 611-123.456 612-123.456 613-123.456 614-123.456 615123456000000000 616123456000000000 617123456000000000 618123456000000000 619123456000000000 620123456000000000 621123456000000000 6221.23456e-0?10 6231.23456e-0?10 6241.23456e-0?10 6251.23456e-0?10 626123 62712.34 62812340000000000 629_123 630123 631123 632123 633123 634_123 635123 636123 637123 638-123 639-_123 640-123 641-123 642-123 643123.456 644123.456 645123.456 646123.456 647123.456 648123.456 649123.456 650123.456 651-123.456 652-123.456 653-123.456 654-123.456 655123456000000000 656123456000000000 657123456000000000 658123456000000000 659123456000000000 660123456000000000 661123456000000000 6621.23456e-0?10 6631.23456e-0?10 6641.23456e-0?10 6651.23456e-0?10 666123 66712.34 66812340000000000 669######## 670# toke.c 671use warnings 'bareword' ; 672#line 25 "bar" 673$a = FRED:: ; 674no warnings 'bareword' ; 675#line 25 "bar" 676$a = FRED:: ; 677EXPECT 678Bareword "FRED::" refers to nonexistent package at bar line 25. 679######## 680# toke.c 681use utf8; 682use open qw( :utf8 :std ); 683use warnings 'bareword' ; 684#line 25 "bar" 685$a = FRÈD:: ; 686no warnings 'bareword' ; 687#line 25 "bar" 688$a = FRÈD:: ; 689EXPECT 690Bareword "FRÈD::" refers to nonexistent package at bar line 25. 691######## 692# toke.c 693use utf8; 694use open qw( :utf8 :std ); 695use warnings 'bareword' ; 696#line 25 "bar" 697$a = ϞϞϞ:: ; 698no warnings 'bareword' ; 699#line 25 "bar" 700$a = ϞϞϞ:: ; 701EXPECT 702Bareword "ϞϞϞ::" refers to nonexistent package at bar line 25. 703######## 704# toke.c 705use warnings 'ambiguous' ; 706sub time {} 707my $a = time() ; 708no warnings 'ambiguous' ; 709my $b = time() ; 710EXPECT 711Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4. 712######## 713# toke.c 714use warnings ; 715eval <<'EOE'; 716# line 30 "foo" 717warn "yelp"; 718{ 719 $_ = " \x{123} " ; 720} 721EOE 722EXPECT 723yelp at foo line 30. 724######## 725# toke.c 726my $a = rand + 4 ; 727$a = rand *^H ; 728$a = rand $^H ; 729EXPECT 730Warning: Use of "rand" without parentheses is ambiguous at - line 2. 731######## 732# toke.c 733$^W = 0 ; 734my $a = rand + 4 ; 735{ 736 no warnings 'ambiguous' ; 737 $a = rand + 4 ; 738 use warnings 'ambiguous' ; 739 $a = rand + 4 ; 740} 741$a = rand + 4 ; 742EXPECT 743Warning: Use of "rand" without parentheses is ambiguous at - line 3. 744Warning: Use of "rand" without parentheses is ambiguous at - line 8. 745Warning: Use of "rand" without parentheses is ambiguous at - line 10. 746######## 747# [perl #97110] 748sub myrand(;$) { } 749sub whatever($) { } 750my $a = myrand + 4 ; 751my $b = whatever + 4 ; 752EXPECT 753Warning: Use of "myrand" without parentheses is ambiguous at - line 4. 754######## 755# toke.c 756use warnings "ambiguous"; 757print for keys %+; # should not warn 758EXPECT 759######## 760# toke.c [This does not warn any more.] 761sub fred {}; 762-fred ; 763sub hank : lvalue {$_} 764--hank; # This should *not* warn [perl #77240] 765EXPECT 766######## 767# toke.c [This does not warn any more.] 768$^W = 0 ; 769sub fred {} ; 770-fred ; 771{ 772 no warnings 'ambiguous' ; 773 -fred ; 774 use warnings 'ambiguous' ; 775 -fred ; 776} 777-fred ; 778EXPECT 779######## 780# toke.c [This does not warn any more.] 781use utf8; 782use open qw( :utf8 :std ); 783sub frèd {}; 784-frèd ; 785EXPECT 786######## 787# toke.c [This does not warn any more.] 788$^W = 0 ; 789use utf8; 790use open qw( :utf8 :std ); 791sub frèd {} ; 792-frèd ; 793{ 794 no warnings 'ambiguous' ; 795 -frèd ; 796 use warnings 'ambiguous' ; 797 -frèd ; 798} 799-frèd ; 800EXPECT 801######## 802# toke.c [This does not warn any more.] 803use utf8; 804use open qw( :utf8 :std ); 805sub ᒍᒘᒊ {}; 806-ᒍᒘᒊ ; 807EXPECT 808######## 809# toke.c [This does not warn any more.] 810$^W = 0 ; 811use utf8; 812use open qw( :utf8 :std ); 813sub ᒍᒘᒊ {} ; 814-ᒍᒘᒊ ; 815{ 816 no warnings 'ambiguous' ; 817 -ᒍᒘᒊ ; 818 use warnings 'ambiguous' ; 819 -ᒍᒘᒊ ; 820} 821-ᒍᒘᒊ ; 822EXPECT 823######## 824# toke.c 825open FOO || time; 826open local *FOO; # should be ok 827EXPECT 828Precedence problem: open FOO should be open(FOO) at - line 2. 829######## 830# toke.c 831use utf8; 832use open qw( :utf8 :std ); 833open FÒÒ || time; 834EXPECT 835Precedence problem: open FÒÒ should be open(FÒÒ) at - line 4. 836######## 837# toke.c 838use utf8; 839use open qw( :utf8 :std ); 840open ᒍOO || time; 841EXPECT 842Precedence problem: open ᒍOO should be open(ᒍOO) at - line 4. 843######## 844# toke.c (and [perl #16184]) 845open FOO => "<&0"; close FOO; 846EXPECT 847######## 848# toke.c 849$^W = 0 ; 850open FOO || time; 851{ 852 no warnings 'precedence' ; 853 open FOO || time; 854 use warnings 'precedence' ; 855 open FOO || time; 856} 857open FOO || time; 858open Foo::BAR; # this should not warn 859EXPECT 860Precedence problem: open FOO should be open(FOO) at - line 3. 861Precedence problem: open FOO should be open(FOO) at - line 8. 862Precedence problem: open FOO should be open(FOO) at - line 10. 863######## 864# toke.c 865$^W = 0 ; 866use utf8; 867use open qw( :utf8 :std ); 868open FÒÒ || time; 869{ 870 no warnings 'precedence' ; 871 open FÒÒ || time; 872 use warnings 'precedence' ; 873 open FÒÒ || time; 874} 875open FÒÒ || time; 876EXPECT 877Precedence problem: open FÒÒ should be open(FÒÒ) at - line 5. 878Precedence problem: open FÒÒ should be open(FÒÒ) at - line 10. 879Precedence problem: open FÒÒ should be open(FÒÒ) at - line 12. 880######## 881# toke.c 882use utf8; 883use open qw( :utf8 :std ); 884$^W = 0 ; 885open ᒍÒÒ || time; 886{ 887 no warnings 'precedence' ; 888 open ᒍÒÒ || time; 889 use warnings 'precedence' ; 890 open ᒍÒÒ || time; 891} 892open ᒍÒÒ || time; 893EXPECT 894Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 5. 895Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 10. 896Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 12. 897######## 898# toke.c 899$^W = 0 ; 900*foo *foo ; 901{ 902 no warnings 'ambiguous' ; 903 *foo *foo ; 904 use warnings 'ambiguous' ; 905 *foo *foo ; 906} 907*foo *foo ; 908# These should not warn [perl #117535]: 909foo**foo ; 910no warnings 'deprecated'; 911sort $*foo ; 912sort $ *foo ; 913EXPECT 914Operator or semicolon missing before *foo at - line 3. 915Ambiguous use of * resolved as operator * at - line 3. 916Operator or semicolon missing before *foo at - line 8. 917Ambiguous use of * resolved as operator * at - line 8. 918Operator or semicolon missing before *foo at - line 10. 919Ambiguous use of * resolved as operator * at - line 10. 920######## 921# toke.c 922$^W = 0 ; 923%foo %foo ; 924{ 925 no warnings 'ambiguous' ; 926 %foo %foo ; 927 use warnings 'ambiguous' ; 928 %foo %foo ; 929} 930%foo %foo ; 931# This should not produce ambiguity warnings [perl #117535]: 932sort $%foo ; 933sort $ %foo ; 934EXPECT 935Operator or semicolon missing before %foo at - line 3. 936Ambiguous use of % resolved as operator % at - line 3. 937Operator or semicolon missing before %foo at - line 8. 938Ambiguous use of % resolved as operator % at - line 8. 939Operator or semicolon missing before %foo at - line 10. 940Ambiguous use of % resolved as operator % at - line 10. 941Bareword found where operator expected at - line 12, near "$%foo" 942 (Missing operator before foo?) 943Bareword found where operator expected at - line 13, near "$ %foo" 944 (Missing operator before foo?) 945Illegal modulus zero at - line 3. 946######## 947# toke.c 948$^W = 0 ; 949&foo &foo ; 950{ 951 no warnings 'ambiguous' ; 952 &foo &foo ; 953 use warnings 'ambiguous' ; 954 &foo &foo ; 955} 956&foo &foo ; 957# These should not warn produce ambiguity warnings [perl #76910]: 958foo&&foo ; 959sort $&foo ; 960sort $ &foo ; 961EXPECT 962Operator or semicolon missing before &foo at - line 3. 963Ambiguous use of & resolved as operator & at - line 3. 964Operator or semicolon missing before &foo at - line 8. 965Ambiguous use of & resolved as operator & at - line 8. 966Operator or semicolon missing before &foo at - line 10. 967Ambiguous use of & resolved as operator & at - line 10. 968Bareword found where operator expected at - line 13, near "$&foo" 969 (Missing operator before foo?) 970Bareword found where operator expected at - line 14, near "$ &foo" 971 (Missing operator before foo?) 972Undefined subroutine &main::foo called at - line 3. 973######## 974# toke.c 975use utf8; 976use open qw( :utf8 :std ); 977$^W = 0 ; 978*foo *foo ; 979{ 980 no warnings 'ambiguous' ; 981 *foo *foo ; 982 use warnings 'ambiguous' ; 983 *foo *foo ; 984} 985*foo *foo ; 986EXPECT 987Operator or semicolon missing before *foo at - line 5. 988Ambiguous use of * resolved as operator * at - line 5. 989Operator or semicolon missing before *foo at - line 10. 990Ambiguous use of * resolved as operator * at - line 10. 991Operator or semicolon missing before *foo at - line 12. 992Ambiguous use of * resolved as operator * at - line 12. 993######## 994# toke.c 995use warnings 'misc' ; 996my $a = "\m" ; 997no warnings 'misc' ; 998$a = "\m" ; 999EXPECT 1000Unrecognized escape \m passed through at - line 3. 1001######## 1002# toke.c 1003use warnings 'misc' ; 1004my $a = "abcd\E" ; 1005no warnings 'misc' ; 1006$a = "abcd\E" ; 1007EXPECT 1008Useless use of \E at - line 3. 1009######## 1010# toke.c 1011use feature 'postderef_qq'; 1012(\$_)->$*; 1013"$_->$*"; 1014(\$_)->$*; 1015"$_->$*"; 1016EXPECT 1017######## 1018# toke.c 1019use warnings 'portable' ; 1020my $a = 0b011111111111111111111111111111110 ; 1021 $a = 0b011111111111111111111111111111111 ; 1022 $a = 0b111111111111111111111111111111111 ; 1023 $a = 0x0fffffffe ; 1024 $a = 0x0ffffffff ; 1025 $a = 0x1ffffffff ; 1026 $a = 0037777777776 ; 1027 $a = 0037777777777 ; 1028 $a = 0047777777777 ; 1029no warnings 'portable' ; 1030 $a = 0b011111111111111111111111111111110 ; 1031 $a = 0b011111111111111111111111111111111 ; 1032 $a = 0b111111111111111111111111111111111 ; 1033 $a = 0x0fffffffe ; 1034 $a = 0x0ffffffff ; 1035 $a = 0x1ffffffff ; 1036 $a = 0037777777776 ; 1037 $a = 0037777777777 ; 1038 $a = 0047777777777 ; 1039EXPECT 1040Binary number > 0b11111111111111111111111111111111 non-portable at - line 5. 1041Hexadecimal number > 0xffffffff non-portable at - line 8. 1042Octal number > 037777777777 non-portable at - line 11. 1043######## 1044# toke.c 1045use warnings 'overflow' ; 1046my $a = 0b011111111111111111111111111111110 ; 1047 $a = 0b011111111111111111111111111111111 ; 1048 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ; 1049 $a = 0x0fffffffe ; 1050 $a = 0x0ffffffff ; 1051 $a = 0x10000000000000000 ; 1052 $a = 0037777777776 ; 1053 $a = 0037777777777 ; 1054 $a = 002000000000000000000000; 1055no warnings 'overflow' ; 1056 $a = 0b011111111111111111111111111111110 ; 1057 $a = 0b011111111111111111111111111111111 ; 1058 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ; 1059 $a = 0x0fffffffe ; 1060 $a = 0x0ffffffff ; 1061 $a = 0x10000000000000000 ; 1062 $a = 0037777777776 ; 1063 $a = 0037777777777 ; 1064 $a = 002000000000000000000000; 1065EXPECT 1066Integer overflow in binary number at - line 5. 1067Integer overflow in hexadecimal number at - line 8. 1068Integer overflow in octal number at - line 11. 1069######## 1070# toke.c 1071BEGIN { $^C = 1; } 1072use warnings 'misc'; 1073dump; 1074CORE::dump; 1075EXPECT 1076dump() better written as CORE::dump() at - line 4. 1077- syntax OK 1078######## 1079# toke.c 1080use warnings 'misc'; 1081use subs qw/dump/; 1082sub dump { print "no warning for overridden dump\n"; } 1083dump; 1084EXPECT 1085no warning for overridden dump 1086######## 1087# toke.c 1088use warnings 'ambiguous'; 1089"@mjd_previously_unused_array"; 1090no warnings 'ambiguous'; 1091"@mjd_previously_unused_array2"; 1092EXPECT 1093Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3. 1094######## 1095# toke.c 1096use utf8; 1097use open qw( :utf8 :std ); 1098use warnings 'ambiguous'; 1099"@mjd_previously_unused_àrray"; 1100no warnings 'ambiguous'; 1101"@mjd_previously_unused_àrray2"; 1102EXPECT 1103Possible unintended interpolation of @mjd_previously_unused_àrray in string at - line 5. 1104######## 1105# toke.c 1106use utf8; 1107use open qw( :utf8 :std ); 1108use warnings 'ambiguous'; 1109"@mjd_previously_unused_ぁrrぁy"; 1110no warnings 'ambiguous'; 1111"@mjd_previously_unused_ぁrrぁy2"; 1112EXPECT 1113Possible unintended interpolation of @mjd_previously_unused_ぁrrぁy in string at - line 5. 1114######## 1115# toke.c 1116# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com 1117use warnings 'regexp'; 1118"foo" =~ /foo/c; 1119"foo" =~ /foo/cg; 1120no warnings 'regexp'; 1121"foo" =~ /foo/c; 1122"foo" =~ /foo/cg; 1123EXPECT 1124Use of /c modifier is meaningless without /g at - line 4. 1125######## 1126# toke.c 1127# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com 1128use warnings 'regexp'; 1129$_ = "ab" ; 1130s/ab/ab/c; 1131s/ab/ab/cg; 1132no warnings 'regexp'; 1133s/ab/ab/c; 1134s/ab/ab/cg; 1135EXPECT 1136Use of /c modifier is meaningless in s/// at - line 5. 1137Use of /c modifier is meaningless in s/// at - line 6. 1138######## 1139-wa 1140# toke.c 1141# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings 1142print "@F\n"; 1143EXPECT 1144 1145######## 1146-w 1147# toke.c 1148# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings 1149print "@F\n"; 1150EXPECT 1151Possible unintended interpolation of @F in string at - line 4. 1152Name "main::F" used only once: possible typo at - line 4. 1153######## 1154-wa 1155# toke.c 1156# 20020414 mjd-perl-patch+@plover.com 1157EXPECT 1158 1159######## 1160# toke.c 1161# 20020414 mjd-perl-patch+@plover.com 1162# In 5.7.3, this emitted "Possible unintended interpolation" warnings 1163use warnings 'ambiguous'; 1164$s = "(@-)(@+)"; 1165EXPECT 1166 1167######## 1168# toke.c 1169# mandatory warning 1170eval q/if ($a) { } elseif ($b) { }/; 1171no warnings "syntax"; 1172eval q/if ($a) { } elseif ($b) { }/; 1173EXPECT 1174elseif should be elsif at (eval 1) line 1. 1175######## 1176# toke.c 1177# mandatory warning 1178eval q/5 6/; 1179no warnings "syntax"; 1180eval q/5 6/; 1181EXPECT 1182Number found where operator expected at (eval 1) line 1, near "5 6" 1183 (Missing operator before 6?) 1184######## 1185# toke.c 1186use warnings "syntax"; no warnings "deprecated"; 1187$_ = $a = 1; 1188$a !=~ /1/; 1189$a !=~ m#1#; 1190$a !=~/1/; 1191$a !=~ y/1//; 1192$a !=~ tr/1//; 1193$a !=~ s/1//; 1194$a != ~/1/; 1195no warnings "syntax"; 1196$a !=~ /1/; 1197$a !=~ m#1#; 1198$a !=~/1/; 1199$a !=~ y/1//; 1200$a !=~ tr/1//; 1201$a !=~ s/1//; 1202EXPECT 1203!=~ should be !~ at - line 4. 1204!=~ should be !~ at - line 5. 1205!=~ should be !~ at - line 6. 1206!=~ should be !~ at - line 7. 1207!=~ should be !~ at - line 8. 1208!=~ should be !~ at - line 9. 1209######## 1210# toke.c 1211our $foo :unique; 1212sub pam :locked; 1213sub glipp :locked { 1214} 1215sub whack_eth ($) : locked { 1216} 1217no warnings 'deprecated'; 1218our $bar :unique; 1219sub zapeth :locked; 1220sub ker_plop :locked { 1221} 1222sub swa_a_p ($) : locked { 1223} 1224EXPECT 1225Use of :unique is deprecated at - line 2. 1226Use of :locked is deprecated at - line 3. 1227Use of :locked is deprecated at - line 4. 1228Use of :locked is deprecated at - line 6. 1229######## 1230# toke.c 1231use warnings "syntax"; use feature 'lexical_subs'; 1232sub proto_after_array(@$); 1233sub proto_after_arref(\@$); 1234sub proto_after_arref2(\[@$]); 1235sub proto_after_arref3(\[@$]_); 1236sub proto_after_hash(%$); 1237sub proto_after_hashref(\%$); 1238sub proto_after_hashref2(\[%$]); 1239sub underscore_last_pos($_); 1240sub underscore2($_;$); 1241sub underscore_fail($_$); 1242sub underscore_after_at(@_); 1243our sub hour (@$); 1244my sub migh (@$); 1245use feature 'state'; 1246state sub estate (@$); 1247package other; 1248sub hour (@$); 1249sub migh (@$); 1250sub estate (@$); 1251no warnings "syntax"; 1252sub proto_after_array(@$); 1253sub proto_after_hash(%$); 1254sub underscore_fail($_$); 1255EXPECT 1256Prototype after '@' for main::proto_after_array : @$ at - line 3. 1257Prototype after '%' for main::proto_after_hash : %$ at - line 7. 1258Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12. 1259Prototype after '@' for main::underscore_after_at : @_ at - line 13. 1260The lexical_subs feature is experimental at - line 14. 1261Prototype after '@' for hour : @$ at - line 14. 1262The lexical_subs feature is experimental at - line 15. 1263Prototype after '@' for migh : @$ at - line 15. 1264The lexical_subs feature is experimental at - line 17. 1265Prototype after '@' for estate : @$ at - line 17. 1266Prototype after '@' for hour : @$ at - line 19. 1267Prototype after '@' for migh : @$ at - line 20. 1268Prototype after '@' for estate : @$ at - line 21. 1269######## 1270# toke.c 1271use warnings "ambiguous"; 1272"foo\nn" =~ /^foo$\n/; 1273"foo\nn" =~ /^foo${\}n/; 1274my $foo = qr/^foo$\n/; 1275my $bar = qr/^foo${\}n/; 1276no warnings "ambiguous"; 1277"foo\nn" =~ /^foo$\n/; 1278"foo\nn" =~ /^foo${\}n/; 1279my $foo = qr/^foo$\n/; 1280my $bar = qr/^foo${\}n/; 1281EXPECT 1282Possible unintended interpolation of $\ in regex at - line 3. 1283Possible unintended interpolation of $\ in regex at - line 5. 1284######## 1285# toke.c 1286use warnings 'syntax' ; 1287my $a = "\o"; 1288my $a = "\o{"; 1289my $a = "\o{}"; 1290no warnings 'syntax' ; 1291my $a = "\o"; 1292my $a = "\o{"; 1293my $a = "\o{}"; 1294EXPECT 1295Missing braces on \o{} at - line 3, within string 1296Missing right brace on \o{ at - line 4, within string 1297Number with no digits at - line 5, within string 1298BEGIN not safe after errors--compilation aborted at - line 6. 1299######## 1300# toke.c 1301use warnings 'digit' ; 1302my $a = "\o{1238456}"; 1303no warnings 'digit' ; 1304my $a = "\o{1238456}"; 1305EXPECT 1306Non-octal character '8'. Resolved as "\o{123}" at - line 3. 1307######## 1308# toke.c 1309use warnings; 1310print ref ? "yes\n" : "no\n" foreach [], ''; # ? is unambiguosly an operator 1311EXPECT 1312yes 1313no 1314######## 1315# toke .c 1316use warnings; 1317$a =~ ?rand?; # ? is not a regex match 1318EXPECT 1319syntax error at - line 3, near "=~ ?" 1320Execution of - aborted due to compilation errors. 1321######## 1322# toke.c 1323BEGIN { 1324 if (ord('A') == 193) { 1325 print "SKIPPED\n# result varies depending on which ebcdic platform"; 1326 exit 0; 1327 } 1328} 1329use warnings; 1330$a = "\c,"; 1331$a = "\c`"; 1332no warnings 'syntax'; 1333$a = "\c,"; 1334$a = "\c`"; 1335EXPECT 1336"\c," is more clearly written simply as "l" at - line 9. 1337"\c`" is more clearly written simply as "\ " at - line 10. 1338######## 1339# toke.c 1340BEGIN { 1341 if (ord('A') == 193) { 1342 print "SKIPPED\n# test is ASCII-specific"; 1343 exit 0; 1344 } 1345} 1346use warnings; 1347my $a = "\c{ack}"; 1348EXPECT 1349OPTION fatal 1350Use ";" instead of "\c{" at - line 9. 1351######## 1352# toke.c 1353BEGIN { 1354 if (ord('A') == 65) { 1355 print "SKIPPED\n# test is EBCDIC-specific"; 1356 exit 0; 1357 } 1358} 1359use warnings; 1360my $a = "\c{ack}"; 1361EXPECT 1362OPTION fatal 1363Sequence "\c{" invalid at - line 9. 1364######## 1365# toke.c 1366my $a = "\câ"; 1367EXPECT 1368OPTION fatal 1369Character following "\c" must be printable ASCII at - line 2. 1370######## 1371# toke.c 1372use warnings 'syntax' ; 1373my $a = qr/foo/du; 1374$a = qr/foo/lai; 1375$a = qr/foo/lil; 1376$a = qr/foo/aia; 1377$a = qr/foo/aaia; 1378no warnings 'syntax' ; 1379my $a = qr/foo/du; 1380EXPECT 1381Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= " 1382Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= " 1383Regexp modifier "/l" may not appear twice at - line 5, near "= " 1384Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= " 1385BEGIN not safe after errors--compilation aborted at - line 8. 1386######## 1387# toke.c 1388# [perl #4362] 1389eval "print q\xabfoo"; 1390print "ok\n" if 1391 $@ =~ /Can't find string terminator "\xab" anywhere before EOF/; 1392EXPECT 1393ok 1394######## 1395# toke.c 1396use utf8; 1397use open qw( :utf8 :std ); 1398use warnings 'ambiguous' ; 1399sub frèd {} 1400$a = ${frèd} ; 1401no warnings 'ambiguous' ; 1402$a = ${frèd} ; 1403EXPECT 1404Ambiguous use of ${frèd} resolved to $frèd at - line 6. 1405######## 1406# toke.c 1407use utf8; 1408use open qw( :utf8 :std ); 1409use warnings 'ambiguous' ; 1410sub f렏 {} 1411$a = ${f렏} ; 1412no warnings 'ambiguous' ; 1413$a = ${f렏} ; 1414EXPECT 1415Ambiguous use of ${f렏} resolved to $f렏 at - line 6. 1416######## 1417# toke.c 1418use utf8; 1419use open qw( :utf8 :std ); 1420use warnings; 1421CORE::렏; 1422EXPECT 1423CORE::렏 is not a keyword at - line 5. 1424######## 1425# toke.c 1426# [perl #16249] 1427print ''; 1428eval this_method_is_fake (); 1429EXPECT 1430Undefined subroutine &main::this_method_is_fake called at - line 4. 1431######## 1432# toke.c 1433# [perl #107002] Erroneous ambiguity warnings 1434sub { # do not actually call require 1435 require a::b . 1; # These used to produce erroneous 1436 require a::b + 1; # ambiguity warnings. 1437} 1438EXPECT 1439######## 1440# toke.c 1441# [perl #113094], [perl #119101], since reverted so no warnings generated 1442use warnings; 1443print "aa" =~ m{^a\{1,2\}$}, "A\n"; 1444print "aa" =~ m{^a\x\{61\}$}, "B\n"; 1445print "a\\x{6F}" =~ m{^a\\x\{6F\}$}, "C\n"; 1446print "a\\o" =~ m{^a\\\x\{6F\}$}, "D\n"; 1447print "a\\\\x{6F}" =~ m{^a\\\\x\{6F\}$}, "E\n"; 1448print "a\\\\o" =~ m{^a\\\\\x\{6F\}$}, "F\n"; 1449print "aa" =~ m{^a{1,2}$}, "G\n"; 1450print "aq" =~ m[^a\[a-z\]$], "H\n"; 1451print "aq" =~ m(^a\(q\)$), "I\n"; 1452EXPECT 1453Illegal hexadecimal digit '\' ignored at - line 5. 1454Illegal hexadecimal digit '\' ignored at - line 7. 1455Illegal hexadecimal digit '\' ignored at - line 9. 1456A 1457B 14581C 1459D 14601E 1461F 14621G 1463H 1464I 1465######## 1466# toke.c 1467#[perl #119123] disallow literal control character variables 1468*{ 1469 Foo 1470}; # shouldn't warn on {\n, even though \n is a control character 1471EXPECT 1472######## 1473# toke.c 1474# [perl #120288] -X at start of line gave spurious warning, where X is not 1475# a filetest operator 1476-a; 1477;-a; 1478EXPECT 1479######## 1480# toke.c 1481# [perl #124113] Compile-time warning with UTF8 variable in array index 1482use warnings; 1483use utf8; 1484my $ = 0; 1485my @array = (0); 1486my $v = $array[ 0 + $ ]; 1487 $v = $array[ $ + 0 ]; 1488EXPECT 1489######## 1490# toke.c 1491# Allow Unicode here doc boundaries 1492use warnings; 1493use utf8; 1494my $v = <<EnFraçais; 1495Comme ca! 1496EnFraçais 1497print $v; 1498EXPECT 1499Comme ca! 1500######## 1501# toke.c 1502# Fix 'Use of "..." without parentheses is ambiguous' warning for 1503# Unicode function names. If not under PERL_UNICODE, this will generate 1504# a "Wide character" warning 1505use utf8; 1506use warnings; 1507sub (;$) { return 0; } 1508my $v = - 5; 1509EXPECT 1510OPTION regex 1511(Wide character.*\n)?Warning: Use of "" without parentheses is ambiguous 1512