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 Scalar value %.*s better written as $%.*s" 39 @a[3] = 2; 40 @a{3} = 2; 41 42 Can't use \\%c to mean $%c in expression 43 $_ = "ab" ; s/(ab)/\1/e; 44 45 Unquoted string "abc" may clash with future reserved word at - line 3. 46 warn(warn_reserved 47 $a = abc; 48 49 Possible attempt to separate words with commas 50 @a = qw(a, b, c) ; 51 52 Possible attempt to put comments in qw() list 53 @a = qw(a b # c) ; 54 55 %s (...) interpreted as function 56 print ("") 57 printf ("") 58 sort ("") 59 60 Ambiguous use of %c{%s%s} resolved to %c%s%s 61 $a = ${time[2]} 62 $a = ${time{2}} 63 64 65 Ambiguous use of %c{%s} resolved to %c%s 66 $a = ${time} 67 sub fred {} $a = ${fred} 68 69 Misplaced _ in number 70 $a = 1_2; 71 $a = 1_2345_6; 72 73 Bareword \"%s\" refers to nonexistent package 74 $a = FRED:: ; 75 76 Ambiguous call resolved as CORE::%s(), qualify as such or use & 77 sub time {} 78 my $a = time() 79 80 Unrecognized escape \\%c passed through 81 $a = "\m" ; 82 83 Useless use of \\E. 84 $a = "abcd\E" ; 85 86 %s number > %s non-portable 87 my $a = 0b011111111111111111111111111111110 ; 88 $a = 0b011111111111111111111111111111111 ; 89 $a = 0b111111111111111111111111111111111 ; 90 $a = 0x0fffffffe ; 91 $a = 0x0ffffffff ; 92 $a = 0x1ffffffff ; 93 $a = 0037777777776 ; 94 $a = 0037777777777 ; 95 $a = 0047777777777 ; 96 97 Integer overflow in binary number 98 my $a = 0b011111111111111111111111111111110 ; 99 $a = 0b011111111111111111111111111111111 ; 100 $a = 0b111111111111111111111111111111111 ; 101 $a = 0x0fffffffe ; 102 $a = 0x0ffffffff ; 103 $a = 0x1ffffffff ; 104 $a = 0037777777776 ; 105 $a = 0037777777777 ; 106 $a = 0047777777777 ; 107 108 dump() better written as CORE::dump() 109 110 Use of /c modifier is meaningless without /g 111 112 Use of /c modifier is meaningless in s/// 113 114 Mandatory Warnings 115 ------------------ 116 Use of "%s" without parentheses is ambiguous [check_uni] 117 rand + 4 118 119 Ambiguous use of -%s resolved as -&%s() [yylex] 120 sub fred {} ; - fred ; 121 122 Precedence problem: open %.*s should be open(%.*s) [yylex] 123 open FOO || die; 124 125 Operator or semicolon missing before %c%s [yylex] 126 Ambiguous use of %c resolved as operator %c 127 *foo *foo 128 129__END__ 130# toke.c 131format STDOUT = 132@<<< @||| @>>> @>>> 133$a $b "abc" 'def' 134. 135no warnings 'deprecated' ; 136format STDOUT = 137@<<< @||| @>>> @>>> 138$a $b "abc" 'def' 139. 140EXPECT 141Use of comma-less variable list is deprecated at - line 4. 142Use of comma-less variable list is deprecated at - line 4. 143Use of comma-less variable list is deprecated at - line 4. 144######## 145# toke.c 146$a =~ m/$foo/sand $bar; 147$a =~ s/$foo/fool/sand $bar; 148$a = <<; 149 150no warnings 'deprecated' ; 151$a =~ m/$foo/sand $bar; 152$a =~ s/$foo/fool/sand $bar; 153$a = <<; 154 155EXPECT 156Having no space between pattern and following word is deprecated at - line 2. 157Having no space between pattern and following word is deprecated at - line 3. 158Use of bare << to mean <<"" is deprecated at - line 4. 159######## 160# toke.c 161use warnings 'syntax' ; 162s/(abc)/\1/; 163no warnings 'syntax' ; 164s/(abc)/\1/; 165EXPECT 166\1 better written as $1 at - line 3. 167######## 168# toke.c 169use warnings 'semicolon' ; 170$a = 1 171&time ; 172no warnings 'semicolon' ; 173$a = 1 174&time ; 175EXPECT 176Semicolon seems to be missing at - line 3. 177######## 178# toke.c 179use warnings 'syntax' ; 180my $a =+ 2 ; 181$a =- 2 ; 182$a =* 2 ; 183$a =% 2 ; 184$a =& 2 ; 185$a =. 2 ; 186$a =^ 2 ; 187$a =| 2 ; 188$a =< 2 ; 189$a =/ 2 ; 190EXPECT 191Reversed += operator at - line 3. 192Reversed -= operator at - line 4. 193Reversed *= operator at - line 5. 194Reversed %= operator at - line 6. 195Reversed &= operator at - line 7. 196Reversed .= operator at - line 8. 197Reversed ^= operator at - line 9. 198Reversed |= operator at - line 10. 199Reversed <= operator at - line 11. 200syntax error at - line 8, near "=." 201syntax error at - line 9, near "=^" 202syntax error at - line 10, near "=|" 203Unterminated <> operator at - line 11. 204######## 205# toke.c 206no warnings 'syntax' ; 207my $a =+ 2 ; 208$a =- 2 ; 209$a =* 2 ; 210$a =% 2 ; 211$a =& 2 ; 212$a =. 2 ; 213$a =^ 2 ; 214$a =| 2 ; 215$a =< 2 ; 216$a =/ 2 ; 217EXPECT 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 224use warnings 'syntax' ; 225my $a = $a[1,2] ; 226no warnings 'syntax' ; 227my $a = $a[1,2] ; 228EXPECT 229Multidimensional syntax $a[1,2] not supported at - line 3. 230######## 231# toke.c 232use warnings 'syntax' ; 233sub fred {} ; $SIG{TERM} = fred; 234no warnings 'syntax' ; 235$SIG{TERM} = fred; 236EXPECT 237You need to quote "fred" at - line 3. 238######## 239# toke.c 240use utf8; 241use open qw( :utf8 :std ); 242use warnings 'syntax' ; 243sub frèd {} ; $SIG{TERM} = frèd; 244no warnings 'syntax' ; 245$SIG{TERM} = frèd; 246EXPECT 247You need to quote "frèd" at - line 5. 248######## 249# toke.c 250use utf8; 251use open qw( :utf8 :std ); 252use warnings 'syntax' ; 253sub ふれど {} ; $SIG{TERM} = ふれど; 254no warnings 'syntax' ; 255$SIG{TERM} = ふれど; 256EXPECT 257You need to quote "ふれど" at - line 5. 258######## 259# toke.c 260use warnings 'syntax' ; 261@a[3] = 2; 262@a{3} = 2; 263no warnings 'syntax' ; 264@a[3] = 2; 265@a{3} = 2; 266EXPECT 267Scalar value @a[3] better written as $a[3] at - line 3. 268Scalar value @a{3} better written as $a{3} at - line 4. 269######## 270# toke.c 271use utf8; 272use open qw( :utf8 :std ); 273use warnings 'syntax' ; 274@à[3] = 2; 275@à{3} = 2; 276no warnings 'syntax' ; 277@à[3] = 2; 278@à{3} = 2; 279EXPECT 280Scalar value @à[3] better written as $à[3] at - line 5. 281Scalar value @à{3} better written as $à{3} at - line 6. 282######## 283# toke.c 284use utf8; 285use open qw( :utf8 :std ); 286use warnings 'syntax' ; 287@ぁ[3] = 2; 288@ぁ{3} = 2; 289no warnings 'syntax' ; 290@ぁ[3] = 2; 291@ぁ{3} = 2; 292EXPECT 293Scalar value @ぁ[3] better written as $ぁ[3] at - line 5. 294Scalar value @ぁ{3} better written as $ぁ{3} at - line 6. 295######## 296# toke.c 297use warnings 'syntax' ; 298$_ = "ab" ; 299s/(ab)/\1/e; 300no warnings 'syntax' ; 301$_ = "ab" ; 302s/(ab)/\1/e; 303EXPECT 304Can't use \1 to mean $1 in expression at - line 4. 305######## 306# toke.c 307use warnings 'reserved' ; 308$a = abc; 309$a = { def 310 311=> 1 }; 312no warnings 'reserved' ; 313$a = abc; 314EXPECT 315Unquoted string "abc" may clash with future reserved word 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. 324######## 325# toke.c 326use warnings 'qw' ; 327@a = qw(a b c # #) ; 328no warnings 'qw' ; 329@a = qw(a b c # #) ; 330EXPECT 331Possible attempt to put comments in qw() list at - line 3. 332######## 333# toke.c 334use warnings 'qw' ; 335@a = qw(a, b, c # #) ; 336no warnings 'qw' ; 337@a = qw(a, b, c # #) ; 338EXPECT 339Possible attempt to separate words with commas at - line 3. 340Possible attempt to put comments in qw() list at - line 3. 341######## 342# toke.c 343use warnings 'syntax' ; 344print (""); 345print ("") and $x = 1; 346print ("") or die; 347print ("") // die; 348print (1+2) * 3 if 0; # only this one should warn 349print (1+2) if 0; 350EXPECT 351print (...) interpreted as function at - line 7. 352######## 353# toke.c 354no warnings 'syntax' ; 355print ("") 356EXPECT 357 358######## 359# toke.c 360use warnings 'syntax' ; 361printf (""); 362printf ("") . ''; 363EXPECT 364printf (...) interpreted as function at - line 4. 365######## 366# toke.c 367no warnings 'syntax' ; 368printf ("") 369EXPECT 370 371######## 372# toke.c 373use warnings 'syntax' ; 374sort (""); 375sort ("") . ''; 376EXPECT 377sort (...) interpreted as function at - line 4. 378######## 379# toke.c 380no warnings 'syntax' ; 381sort ("") 382EXPECT 383 384######## 385# toke.c 386use warnings 'ambiguous' ; 387$a = ${time[2]}; 388no warnings 'ambiguous' ; 389$a = ${time[2]}; 390EXPECT 391Ambiguous use of ${time[...]} resolved to $time[...] at - line 3. 392######## 393# toke.c 394use warnings 'ambiguous' ; 395$a = ${time{2}}; 396EXPECT 397Ambiguous use of ${time{...}} resolved to $time{...} at - line 3. 398######## 399# toke.c 400no warnings 'ambiguous' ; 401$a = ${time{2}}; 402EXPECT 403 404######## 405# toke.c 406use warnings 'ambiguous' ; 407$a = ${time} ; 408no warnings 'ambiguous' ; 409$a = ${time} ; 410EXPECT 411Ambiguous use of ${time} resolved to $time at - line 3. 412######## 413# toke.c 414use warnings 'ambiguous' ; 415sub fred {} 416$a = ${fred} ; 417no warnings 'ambiguous' ; 418$a = ${fred} ; 419EXPECT 420Ambiguous use of ${fred} resolved to $fred at - line 4. 421######## 422# toke.c 423use warnings 'syntax' ; 424$a = _123; print "$a\n"; #( 3 string) 425$a = 1_23; print "$a\n"; 426$a = 12_3; print "$a\n"; 427$a = 123_; print "$a\n"; # 6 428$a = _+123; print "$a\n"; # 7 string) 429$a = +_123; print "$a\n"; #( 8 string) 430$a = +1_23; print "$a\n"; 431$a = +12_3; print "$a\n"; 432$a = +123_; print "$a\n"; # 11 433$a = _-123; print "$a\n"; #(12 string) 434$a = -_123; print "$a\n"; #(13 string) 435$a = -1_23; print "$a\n"; 436$a = -12_3; print "$a\n"; 437$a = -123_; print "$a\n"; # 16 438$a = 123._456; print "$a\n"; # 17 439$a = 123.4_56; print "$a\n"; 440$a = 123.45_6; print "$a\n"; 441$a = 123.456_; print "$a\n"; # 20 442$a = +123._456; print "$a\n"; # 21 443$a = +123.4_56; print "$a\n"; 444$a = +123.45_6; print "$a\n"; 445$a = +123.456_; print "$a\n"; # 24 446$a = -123._456; print "$a\n"; # 25 447$a = -123.4_56; print "$a\n"; 448$a = -123.45_6; print "$a\n"; 449$a = -123.456_; print "$a\n"; # 28 450$a = 123.456E_12; printf("%.0f\n", $a); # 29 451$a = 123.456E1_2; printf("%.0f\n", $a); 452$a = 123.456E12_; printf("%.0f\n", $a); # 31 453$a = 123.456E_+12; printf("%.0f\n", $a); # 32 454$a = 123.456E+_12; printf("%.0f\n", $a); # 33 455$a = 123.456E+1_2; printf("%.0f\n", $a); 456$a = 123.456E+12_; printf("%.0f\n", $a); # 35 457$a = 123.456E_-12; print "$a\n"; # 36 458$a = 123.456E-_12; print "$a\n"; # 37 459$a = 123.456E-1_2; print "$a\n"; 460$a = 123.456E-12_; print "$a\n"; # 39 461$a = 1__23; print "$a\n"; # 40 462$a = 12.3__4; print "$a\n"; # 41 463$a = 12.34e1__2; printf("%.0f\n", $a); # 42 464no warnings 'syntax' ; 465$a = _123; print "$a\n"; 466$a = 1_23; print "$a\n"; 467$a = 12_3; print "$a\n"; 468$a = 123_; print "$a\n"; 469$a = _+123; print "$a\n"; 470$a = +_123; print "$a\n"; 471$a = +1_23; print "$a\n"; 472$a = +12_3; print "$a\n"; 473$a = +123_; print "$a\n"; 474$a = _-123; print "$a\n"; 475$a = -_123; print "$a\n"; 476$a = -1_23; print "$a\n"; 477$a = -12_3; print "$a\n"; 478$a = -123_; print "$a\n"; 479$a = 123._456; print "$a\n"; 480$a = 123.4_56; print "$a\n"; 481$a = 123.45_6; print "$a\n"; 482$a = 123.456_; print "$a\n"; 483$a = +123._456; print "$a\n"; 484$a = +123.4_56; print "$a\n"; 485$a = +123.45_6; print "$a\n"; 486$a = +123.456_; print "$a\n"; 487$a = -123._456; print "$a\n"; 488$a = -123.4_56; print "$a\n"; 489$a = -123.45_6; print "$a\n"; 490$a = -123.456_; print "$a\n"; 491$a = 123.456E_12; printf("%.0f\n", $a); 492$a = 123.456E1_2; printf("%.0f\n", $a); 493$a = 123.456E12_; printf("%.0f\n", $a); 494$a = 123.456E_+12; printf("%.0f\n", $a); 495$a = 123.456E+_12; printf("%.0f\n", $a); 496$a = 123.456E+1_2; printf("%.0f\n", $a); 497$a = 123.456E+12_; printf("%.0f\n", $a); 498$a = 123.456E_-12; print "$a\n"; 499$a = 123.456E-_12; print "$a\n"; 500$a = 123.456E-1_2; print "$a\n"; 501$a = 123.456E-12_; print "$a\n"; 502$a = 1__23; print "$a\n"; 503$a = 12.3__4; print "$a\n"; 504$a = 12.34e1__2; printf("%.0f\n", $a); 505EXPECT 506OPTIONS regex 507Misplaced _ in number at - line 6. 508Misplaced _ in number at - line 11. 509Misplaced _ in number at - line 16. 510Misplaced _ in number at - line 17. 511Misplaced _ in number at - line 20. 512Misplaced _ in number at - line 21. 513Misplaced _ in number at - line 24. 514Misplaced _ in number at - line 25. 515Misplaced _ in number at - line 28. 516Misplaced _ in number at - line 29. 517Misplaced _ in number at - line 31. 518Misplaced _ in number at - line 32. 519Misplaced _ in number at - line 33. 520Misplaced _ in number at - line 35. 521Misplaced _ in number at - line 36. 522Misplaced _ in number at - line 37. 523Misplaced _ in number at - line 39. 524Misplaced _ in number at - line 40. 525Misplaced _ in number at - line 41. 526Misplaced _ in number at - line 42. 527_123 528123 529123 530123 531123 532_123 533123 534123 535123 536-123 537-_123 538-123 539-123 540-123 541123.456 542123.456 543123.456 544123.456 545123.456 546123.456 547123.456 548123.456 549-123.456 550-123.456 551-123.456 552-123.456 553123456000000000 554123456000000000 555123456000000000 556123456000000000 557123456000000000 558123456000000000 559123456000000000 5601.23456e-0?10 5611.23456e-0?10 5621.23456e-0?10 5631.23456e-0?10 564123 56512.34 56612340000000000 567_123 568123 569123 570123 571123 572_123 573123 574123 575123 576-123 577-_123 578-123 579-123 580-123 581123.456 582123.456 583123.456 584123.456 585123.456 586123.456 587123.456 588123.456 589-123.456 590-123.456 591-123.456 592-123.456 593123456000000000 594123456000000000 595123456000000000 596123456000000000 597123456000000000 598123456000000000 599123456000000000 6001.23456e-0?10 6011.23456e-0?10 6021.23456e-0?10 6031.23456e-0?10 604123 60512.34 60612340000000000 607######## 608# toke.c 609use warnings 'bareword' ; 610#line 25 "bar" 611$a = FRED:: ; 612no warnings 'bareword' ; 613#line 25 "bar" 614$a = FRED:: ; 615EXPECT 616Bareword "FRED::" refers to nonexistent package at bar line 25. 617######## 618# toke.c 619use utf8; 620use open qw( :utf8 :std ); 621use warnings 'bareword' ; 622#line 25 "bar" 623$a = FRÈD:: ; 624no warnings 'bareword' ; 625#line 25 "bar" 626$a = FRÈD:: ; 627EXPECT 628Bareword "FRÈD::" refers to nonexistent package at bar line 25. 629######## 630# toke.c 631use utf8; 632use open qw( :utf8 :std ); 633use warnings 'bareword' ; 634#line 25 "bar" 635$a = ϞϞϞ:: ; 636no warnings 'bareword' ; 637#line 25 "bar" 638$a = ϞϞϞ:: ; 639EXPECT 640Bareword "ϞϞϞ::" refers to nonexistent package at bar line 25. 641######## 642# toke.c 643use warnings 'ambiguous' ; 644sub time {} 645my $a = time() ; 646no warnings 'ambiguous' ; 647my $b = time() ; 648EXPECT 649Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4. 650######## 651# toke.c 652use warnings ; 653eval <<'EOE'; 654# line 30 "foo" 655warn "yelp"; 656{ 657 $_ = " \x{123} " ; 658} 659EOE 660EXPECT 661yelp at foo line 30. 662######## 663# toke.c 664my $a = rand + 4 ; 665EXPECT 666Warning: Use of "rand" without parentheses is ambiguous at - line 2. 667######## 668# toke.c 669$^W = 0 ; 670my $a = rand + 4 ; 671{ 672 no warnings 'ambiguous' ; 673 $a = rand + 4 ; 674 use warnings 'ambiguous' ; 675 $a = rand + 4 ; 676} 677$a = rand + 4 ; 678EXPECT 679Warning: Use of "rand" without parentheses is ambiguous at - line 3. 680Warning: Use of "rand" without parentheses is ambiguous at - line 8. 681Warning: Use of "rand" without parentheses is ambiguous at - line 10. 682######## 683# [perl #97110] 684sub myrand(;$) { } 685sub whatever($) { } 686my $a = myrand + 4 ; 687my $b = whatever + 4 ; 688EXPECT 689Warning: Use of "myrand" without parentheses is ambiguous at - line 4. 690######## 691# toke.c 692use warnings "ambiguous"; 693print for keys %+; # should not warn 694EXPECT 695######## 696# toke.c 697sub fred {}; 698-fred ; 699EXPECT 700Ambiguous use of -fred resolved as -&fred() at - line 3. 701######## 702# toke.c 703$^W = 0 ; 704sub fred {} ; 705-fred ; 706{ 707 no warnings 'ambiguous' ; 708 -fred ; 709 use warnings 'ambiguous' ; 710 -fred ; 711} 712-fred ; 713EXPECT 714Ambiguous use of -fred resolved as -&fred() at - line 4. 715Ambiguous use of -fred resolved as -&fred() at - line 9. 716Ambiguous use of -fred resolved as -&fred() at - line 11. 717######## 718# toke.c 719use utf8; 720use open qw( :utf8 :std ); 721sub frèd {}; 722-frèd ; 723EXPECT 724Ambiguous use of -frèd resolved as -&frèd() at - line 5. 725######## 726# toke.c 727$^W = 0 ; 728use utf8; 729use open qw( :utf8 :std ); 730sub frèd {} ; 731-frèd ; 732{ 733 no warnings 'ambiguous' ; 734 -frèd ; 735 use warnings 'ambiguous' ; 736 -frèd ; 737} 738-frèd ; 739EXPECT 740Ambiguous use of -frèd resolved as -&frèd() at - line 6. 741Ambiguous use of -frèd resolved as -&frèd() at - line 11. 742Ambiguous use of -frèd resolved as -&frèd() at - line 13. 743######## 744# toke.c 745use utf8; 746use open qw( :utf8 :std ); 747sub ᒍᒘᒊ {}; 748-ᒍᒘᒊ ; 749EXPECT 750Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 5. 751######## 752# toke.c 753$^W = 0 ; 754use utf8; 755use open qw( :utf8 :std ); 756sub ᒍᒘᒊ {} ; 757-ᒍᒘᒊ ; 758{ 759 no warnings 'ambiguous' ; 760 -ᒍᒘᒊ ; 761 use warnings 'ambiguous' ; 762 -ᒍᒘᒊ ; 763} 764-ᒍᒘᒊ ; 765EXPECT 766Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 6. 767Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 11. 768Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 13. 769######## 770# toke.c 771open FOO || time; 772open local *FOO; # should be ok 773EXPECT 774Precedence problem: open FOO should be open(FOO) at - line 2. 775######## 776# toke.c 777use utf8; 778use open qw( :utf8 :std ); 779open FÒÒ || time; 780EXPECT 781Precedence problem: open FÒÒ should be open(FÒÒ) at - line 4. 782######## 783# toke.c 784use utf8; 785use open qw( :utf8 :std ); 786open ᒍOO || time; 787EXPECT 788Precedence problem: open ᒍOO should be open(ᒍOO) at - line 4. 789######## 790# toke.c (and [perl #16184]) 791open FOO => "<&0"; close FOO; 792EXPECT 793######## 794# toke.c 795$^W = 0 ; 796open FOO || time; 797{ 798 no warnings 'precedence' ; 799 open FOO || time; 800 use warnings 'precedence' ; 801 open FOO || time; 802} 803open FOO || time; 804open Foo::BAR; # this should not warn 805EXPECT 806Precedence problem: open FOO should be open(FOO) at - line 3. 807Precedence problem: open FOO should be open(FOO) at - line 8. 808Precedence problem: open FOO should be open(FOO) at - line 10. 809######## 810# toke.c 811$^W = 0 ; 812use utf8; 813use open qw( :utf8 :std ); 814open FÒÒ || time; 815{ 816 no warnings 'precedence' ; 817 open FÒÒ || time; 818 use warnings 'precedence' ; 819 open FÒÒ || time; 820} 821open FÒÒ || time; 822EXPECT 823Precedence problem: open FÒÒ should be open(FÒÒ) at - line 5. 824Precedence problem: open FÒÒ should be open(FÒÒ) at - line 10. 825Precedence problem: open FÒÒ should be open(FÒÒ) at - line 12. 826######## 827# toke.c 828use utf8; 829use open qw( :utf8 :std ); 830$^W = 0 ; 831open ᒍÒÒ || time; 832{ 833 no warnings 'precedence' ; 834 open ᒍÒÒ || time; 835 use warnings 'precedence' ; 836 open ᒍÒÒ || time; 837} 838open ᒍÒÒ || time; 839EXPECT 840Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 5. 841Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 10. 842Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 12. 843######## 844# toke.c 845$^W = 0 ; 846*foo *foo ; 847{ 848 no warnings 'ambiguous' ; 849 *foo *foo ; 850 use warnings 'ambiguous' ; 851 *foo *foo ; 852} 853*foo *foo ; 854EXPECT 855Operator or semicolon missing before *foo at - line 3. 856Ambiguous use of * resolved as operator * at - line 3. 857Operator or semicolon missing before *foo at - line 8. 858Ambiguous use of * resolved as operator * at - line 8. 859Operator or semicolon missing before *foo at - line 10. 860Ambiguous use of * resolved as operator * at - line 10. 861######## 862# toke.c 863use utf8; 864use open qw( :utf8 :std ); 865$^W = 0 ; 866*foo *foo ; 867{ 868 no warnings 'ambiguous' ; 869 *foo *foo ; 870 use warnings 'ambiguous' ; 871 *foo *foo ; 872} 873*foo *foo ; 874EXPECT 875Operator or semicolon missing before *foo at - line 5. 876Ambiguous use of * resolved as operator * at - line 5. 877Operator or semicolon missing before *foo at - line 10. 878Ambiguous use of * resolved as operator * at - line 10. 879Operator or semicolon missing before *foo at - line 12. 880Ambiguous use of * resolved as operator * at - line 12. 881######## 882# toke.c 883use warnings 'misc' ; 884my $a = "\m" ; 885no warnings 'misc' ; 886$a = "\m" ; 887EXPECT 888Unrecognized escape \m passed through at - line 3. 889######## 890# toke.c 891use warnings 'misc' ; 892my $a = "abcd\E" ; 893no warnings 'misc' ; 894$a = "abcd\E" ; 895EXPECT 896Useless use of \E at - line 3. 897######## 898# toke.c 899use warnings 'portable' ; 900my $a = 0b011111111111111111111111111111110 ; 901 $a = 0b011111111111111111111111111111111 ; 902 $a = 0b111111111111111111111111111111111 ; 903 $a = 0x0fffffffe ; 904 $a = 0x0ffffffff ; 905 $a = 0x1ffffffff ; 906 $a = 0037777777776 ; 907 $a = 0037777777777 ; 908 $a = 0047777777777 ; 909no warnings 'portable' ; 910 $a = 0b011111111111111111111111111111110 ; 911 $a = 0b011111111111111111111111111111111 ; 912 $a = 0b111111111111111111111111111111111 ; 913 $a = 0x0fffffffe ; 914 $a = 0x0ffffffff ; 915 $a = 0x1ffffffff ; 916 $a = 0037777777776 ; 917 $a = 0037777777777 ; 918 $a = 0047777777777 ; 919EXPECT 920Binary number > 0b11111111111111111111111111111111 non-portable at - line 5. 921Hexadecimal number > 0xffffffff non-portable at - line 8. 922Octal number > 037777777777 non-portable at - line 11. 923######## 924# toke.c 925use warnings 'overflow' ; 926my $a = 0b011111111111111111111111111111110 ; 927 $a = 0b011111111111111111111111111111111 ; 928 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ; 929 $a = 0x0fffffffe ; 930 $a = 0x0ffffffff ; 931 $a = 0x10000000000000000 ; 932 $a = 0037777777776 ; 933 $a = 0037777777777 ; 934 $a = 002000000000000000000000; 935no warnings 'overflow' ; 936 $a = 0b011111111111111111111111111111110 ; 937 $a = 0b011111111111111111111111111111111 ; 938 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ; 939 $a = 0x0fffffffe ; 940 $a = 0x0ffffffff ; 941 $a = 0x10000000000000000 ; 942 $a = 0037777777776 ; 943 $a = 0037777777777 ; 944 $a = 002000000000000000000000; 945EXPECT 946Integer overflow in binary number at - line 5. 947Integer overflow in hexadecimal number at - line 8. 948Integer overflow in octal number at - line 11. 949######## 950# toke.c 951BEGIN { $^C = 1; } 952use warnings 'misc'; 953dump; 954CORE::dump; 955EXPECT 956dump() better written as CORE::dump() at - line 4. 957- syntax OK 958######## 959# toke.c 960use warnings 'misc'; 961use subs qw/dump/; 962sub dump { print "no warning for overridden dump\n"; } 963dump; 964EXPECT 965no warning for overridden dump 966######## 967# toke.c 968use warnings 'ambiguous'; 969"@mjd_previously_unused_array"; 970no warnings 'ambiguous'; 971"@mjd_previously_unused_array2"; 972EXPECT 973Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3. 974######## 975# toke.c 976use utf8; 977use open qw( :utf8 :std ); 978use warnings 'ambiguous'; 979"@mjd_previously_unused_àrray"; 980no warnings 'ambiguous'; 981"@mjd_previously_unused_àrray2"; 982EXPECT 983Possible unintended interpolation of @mjd_previously_unused_àrray in string at - line 5. 984######## 985# toke.c 986use utf8; 987use open qw( :utf8 :std ); 988use warnings 'ambiguous'; 989"@mjd_previously_unused_ぁrrぁy"; 990no warnings 'ambiguous'; 991"@mjd_previously_unused_ぁrrぁy2"; 992EXPECT 993Possible unintended interpolation of @mjd_previously_unused_ぁrrぁy in string at - line 5. 994######## 995# toke.c 996# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com 997use warnings 'regexp'; 998"foo" =~ /foo/c; 999"foo" =~ /foo/cg; 1000no warnings 'regexp'; 1001"foo" =~ /foo/c; 1002"foo" =~ /foo/cg; 1003EXPECT 1004Use of /c modifier is meaningless without /g at - line 4. 1005######## 1006# toke.c 1007# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com 1008use warnings 'regexp'; 1009$_ = "ab" ; 1010s/ab/ab/c; 1011s/ab/ab/cg; 1012no warnings 'regexp'; 1013s/ab/ab/c; 1014s/ab/ab/cg; 1015EXPECT 1016Use of /c modifier is meaningless in s/// at - line 5. 1017Use of /c modifier is meaningless in s/// at - line 6. 1018######## 1019-wa 1020# toke.c 1021# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings 1022print "@F\n"; 1023EXPECT 1024 1025######## 1026-w 1027# toke.c 1028# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings 1029print "@F\n"; 1030EXPECT 1031Possible unintended interpolation of @F in string at - line 4. 1032Name "main::F" used only once: possible typo at - line 4. 1033######## 1034-wa 1035# toke.c 1036# 20020414 mjd-perl-patch+@plover.com 1037EXPECT 1038 1039######## 1040# toke.c 1041# 20020414 mjd-perl-patch+@plover.com 1042# In 5.7.3, this emitted "Possible unintended interpolation" warnings 1043use warnings 'ambiguous'; 1044$s = "(@-)(@+)"; 1045EXPECT 1046 1047######## 1048# toke.c 1049# mandatory warning 1050eval q/if ($a) { } elseif ($b) { }/; 1051no warnings "syntax"; 1052eval q/if ($a) { } elseif ($b) { }/; 1053EXPECT 1054elseif should be elsif at (eval 1) line 1. 1055######## 1056# toke.c 1057# mandatory warning 1058eval q/5 6/; 1059no warnings "syntax"; 1060eval q/5 6/; 1061EXPECT 1062Number found where operator expected at (eval 1) line 1, near "5 6" 1063 (Missing operator before 6?) 1064######## 1065# toke.c 1066use warnings "syntax"; 1067$_ = $a = 1; 1068$a !=~ /1/; 1069$a !=~ m#1#; 1070$a !=~/1/; 1071$a !=~ ?/?; 1072$a !=~ y/1//; 1073$a !=~ tr/1//; 1074$a !=~ s/1//; 1075$a != ~/1/; 1076no warnings "syntax"; 1077$a !=~ /1/; 1078$a !=~ m#1#; 1079$a !=~/1/; 1080$a !=~ ?/?; 1081$a !=~ y/1//; 1082$a !=~ tr/1//; 1083$a !=~ s/1//; 1084EXPECT 1085!=~ should be !~ at - line 4. 1086!=~ should be !~ at - line 5. 1087!=~ should be !~ at - line 6. 1088!=~ should be !~ at - line 7. 1089!=~ should be !~ at - line 8. 1090!=~ should be !~ at - line 9. 1091!=~ should be !~ at - line 10. 1092######## 1093# toke.c 1094our $foo :unique; 1095sub pam :locked; 1096sub glipp :locked { 1097} 1098sub whack_eth ($) : locked { 1099} 1100no warnings 'deprecated'; 1101our $bar :unique; 1102sub zapeth :locked; 1103sub ker_plop :locked { 1104} 1105sub swa_a_p ($) : locked { 1106} 1107EXPECT 1108Use of :unique is deprecated at - line 2. 1109Use of :locked is deprecated at - line 3. 1110Use of :locked is deprecated at - line 4. 1111Use of :locked is deprecated at - line 6. 1112######## 1113# toke.c 1114use warnings "syntax"; 1115sub proto_after_array(@$); 1116sub proto_after_arref(\@$); 1117sub proto_after_arref2(\[@$]); 1118sub proto_after_arref3(\[@$]_); 1119sub proto_after_hash(%$); 1120sub proto_after_hashref(\%$); 1121sub proto_after_hashref2(\[%$]); 1122sub underscore_last_pos($_); 1123sub underscore2($_;$); 1124sub underscore_fail($_$); 1125sub underscore_after_at(@_); 1126no warnings "syntax"; 1127sub proto_after_array(@$); 1128sub proto_after_hash(%$); 1129sub underscore_fail($_$); 1130EXPECT 1131Prototype after '@' for main::proto_after_array : @$ at - line 3. 1132Prototype after '%' for main::proto_after_hash : %$ at - line 7. 1133Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12. 1134Prototype after '@' for main::underscore_after_at : @_ at - line 13. 1135######## 1136# toke.c 1137use warnings "ambiguous"; 1138"foo\nn" =~ /^foo$\n/; 1139"foo\nn" =~ /^foo${\}n/; 1140my $foo = qr/^foo$\n/; 1141my $bar = qr/^foo${\}n/; 1142no warnings "ambiguous"; 1143"foo\nn" =~ /^foo$\n/; 1144"foo\nn" =~ /^foo${\}n/; 1145my $foo = qr/^foo$\n/; 1146my $bar = qr/^foo${\}n/; 1147EXPECT 1148Possible unintended interpolation of $\ in regex at - line 3. 1149Possible unintended interpolation of $\ in regex at - line 5. 1150######## 1151# toke.c 1152use warnings 'syntax' ; 1153my $a = "\o"; 1154my $a = "\o{"; 1155my $a = "\o{}"; 1156no warnings 'syntax' ; 1157my $a = "\o"; 1158my $a = "\o{"; 1159my $a = "\o{}"; 1160EXPECT 1161Missing braces on \o{} at - line 3, within string 1162Missing right brace on \o{ at - line 4, within string 1163Number with no digits at - line 5, within string 1164BEGIN not safe after errors--compilation aborted at - line 6. 1165######## 1166# toke.c 1167use warnings 'digit' ; 1168my $a = "\o{1238456}"; 1169no warnings 'digit' ; 1170my $a = "\o{1238456}"; 1171EXPECT 1172Non-octal character '8'. Resolved as "\o{123}" at - line 3. 1173######## 1174# toke.c 1175use warnings; 1176my $a = "foo"; 1177print $a =~ ?f? ? "yes\n" : "no\n" foreach 0..2; 1178EXPECT 1179Use of ?PATTERN? without explicit operator is deprecated at - line 4. 1180yes 1181no 1182no 1183######## 1184# toke.c 1185use warnings; 1186my $a = "\c{ack}"; 1187$a = "\c,"; 1188$a = "\c`"; 1189no warnings 'syntax'; 1190$a = "\c{ack}"; 1191$a = "\c,"; 1192$a = "\c`"; 1193no warnings 'deprecated'; 1194EXPECT 1195"\c{" is deprecated and is more clearly written as ";" at - line 3. 1196"\c," is more clearly written simply as "l" at - line 4. 1197"\c`" is more clearly written simply as "\ " at - line 5. 1198"\c{" is deprecated and is more clearly written as ";" at - line 7. 1199######## 1200# toke.c 1201use warnings 'syntax' ; 1202my $a = qr/foo/du; 1203$a = qr/foo/lai; 1204$a = qr/foo/lil; 1205$a = qr/foo/aia; 1206$a = qr/foo/aaia; 1207no warnings 'syntax' ; 1208my $a = qr/foo/du; 1209EXPECT 1210Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= " 1211Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= " 1212Regexp modifier "/l" may not appear twice at - line 5, near "= " 1213Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= " 1214BEGIN not safe after errors--compilation aborted at - line 8. 1215######## 1216# toke.c 1217# [perl #4362] 1218eval "print q\xabfoo"; 1219print "ok\n" if 1220 $@ =~ /Can't find string terminator "\xab" anywhere before EOF/; 1221EXPECT 1222ok 1223######## 1224# toke.c 1225use utf8; 1226use open qw( :utf8 :std ); 1227use warnings 'ambiguous' ; 1228sub frèd {} 1229$a = ${frèd} ; 1230no warnings 'ambiguous' ; 1231$a = ${frèd} ; 1232EXPECT 1233Ambiguous use of ${frèd} resolved to $frèd at - line 6. 1234######## 1235# toke.c 1236use utf8; 1237use open qw( :utf8 :std ); 1238use warnings 'ambiguous' ; 1239sub f렏 {} 1240$a = ${f렏} ; 1241no warnings 'ambiguous' ; 1242$a = ${f렏} ; 1243EXPECT 1244Ambiguous use of ${f렏} resolved to $f렏 at - line 6. 1245######## 1246# toke.c 1247use utf8; 1248use open qw( :utf8 :std ); 1249use warnings; 1250CORE::렏; 1251EXPECT 1252CORE::렏 is not a keyword at - line 5. 1253