1toke.c AOK 2 3 we seem to have lost a few ambiguous warnings!! 4 5 Prototype after '@' for main::foo 6 sub foo (@$) 7 8 Illegal character in prototype for main::foo 9 sub foo (x) 10 11 \1 better written as $1 12 use warnings 'syntax' ; 13 s/(abc)/\1/; 14 15 warn(warn_nosemi) 16 Semicolon seems to be missing 17 $a = 1 18 &time ; 19 20 21 Reversed %c= operator 22 my $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 $a =/ 2 ; 32 33 Multidimensional syntax %.*s not supported 34 my $a = $a[1,2] ; 35 36 You need to quote \"%s\"" 37 sub fred {} ; $SIG{TERM} = fred; 38 39 Can't use \\%c to mean $%c in expression 40 $_ = "ab" ; s/(ab)/\1/e; 41 42 Unquoted string "abc" may clash with future reserved word at - line 3. 43 warn(warn_reserved 44 $a = abc; 45 46 Possible attempt to separate words with commas 47 @a = qw(a, b, c) ; 48 49 Possible attempt to put comments in qw() list 50 @a = qw(a b # c) ; 51 52 %s (...) interpreted as function 53 print ("") 54 printf ("") 55 sort ("") 56 57 Old package separator used in string 58 "$foo'bar" 59 "@foo'bar" 60 "$#foo'bar" 61 62 Ambiguous use of %c{%s%s} resolved to %c%s%s 63 $a = ${time[2]} 64 $a = ${time{2}} 65 66 67 Ambiguous use of %c{%s} resolved to %c%s 68 $a = ${time} 69 sub fred {} $a = ${fred} 70 71 Misplaced _ in number 72 $a = 1_2; 73 $a = 1_2345_6; 74 75 Bareword \"%s\" refers to nonexistent package 76 $a = FRED:: ; 77 78 Ambiguous call resolved as CORE::%s(), qualify as such or use & 79 sub time {} 80 my $a = time() 81 82 Unrecognized escape \\%c passed through 83 $a = "\m" ; 84 85 Useless use of \\E. 86 $a = "abcd\E" ; 87 88 Postfix dereference is experimental 89 90 %s number > %s non-portable 91 my $a = 0b011111111111111111111111111111110 ; 92 $a = 0b011111111111111111111111111111111 ; 93 $a = 0b111111111111111111111111111111111 ; 94 $a = 0x0fffffffe ; 95 $a = 0x0ffffffff ; 96 $a = 0x1ffffffff ; 97 $a = 0037777777776 ; 98 $a = 0037777777777 ; 99 $a = 0047777777777 ; 100 101 Integer overflow in binary number 102 my $a = 0b011111111111111111111111111111110 ; 103 $a = 0b011111111111111111111111111111111 ; 104 $a = 0b111111111111111111111111111111111 ; 105 $a = 0x0fffffffe ; 106 $a = 0x0ffffffff ; 107 $a = 0x1ffffffff ; 108 $a = 0037777777776 ; 109 $a = 0037777777777 ; 110 $a = 0047777777777 ; 111 112 Use of /c modifier is meaningless without /g 113 114 Use of /c modifier is meaningless in s/// 115 116 Mandatory Warnings 117 ------------------ 118 Use of "%s" without parentheses is ambiguous [check_uni] 119 rand + 4 120 121 Ambiguous use of -%s resolved as -&%s() [yylex] 122 sub fred {} ; - fred ; 123 124 Precedence problem: open %.*s should be open(%.*s) [yylex] 125 open FOO || die; 126 127 Operator or semicolon missing before %c%s [yylex] 128 Ambiguous use of %c resolved as operator %c 129 *foo *foo 130 131__END__ 132use utf8; 133use open qw( :utf8 :std ); 134use warnings; 135eval "sub fòò (@\$\0) {}"; 136EXPECT 137Prototype after '@' for main::fòò : @$\0 at (eval 1) line 1. 138Illegal character in prototype for main::fòò : @$\0 at (eval 1) line 1. 139######## 140use utf8; 141use open qw( :utf8 :std ); 142use warnings; 143eval "sub foo (@\0) {}"; 144eval "sub foo2 :prototype(@\0) {}"; 145EXPECT 146Prototype after '@' for main::foo : @\0 at (eval 1) line 1. 147Illegal character in prototype for main::foo : @\0 at (eval 1) line 1. 148Prototype after '@' for main::foo2 : @\x{0} at (eval 2) line 1. 149Illegal character in prototype for main::foo2 : @\x{0} at (eval 2) line 1. 150######## 151BEGIN { 152 if (ord('A') == 193) { 153 print "SKIPPED\n# Different results on EBCDIC"; 154 exit 0; 155 } 156} 157use utf8; 158use open qw( :utf8 :std ); 159use warnings; 160BEGIN { $::{"foo"} = "\@\$\0L\351on" } 161BEGIN { eval "sub foo (@\$\0L\x{c3}\x{a9}on) {}"; } 162EXPECT 163Prototype after '@' for main::foo : @$\x{0}L... at (eval 1) line 1. 164Illegal character in prototype for main::foo : @$\x{0}L... at (eval 1) line 1. 165######## 166use utf8; 167use open qw( :utf8 :std ); 168use warnings; 169BEGIN { eval "sub foo (@\0) {}"; } 170EXPECT 171Prototype after '@' for main::foo : @\0 at (eval 1) line 1. 172Illegal character in prototype for main::foo : @\0 at (eval 1) line 1. 173######## 174use warnings; 175eval "sub foo (@\xAB) {}"; 176EXPECT 177Prototype after '@' for main::foo : @\x{ab} at (eval 1) line 1. 178Illegal character in prototype for main::foo : @\x{ab} at (eval 1) line 1. 179######## 180use utf8; 181use open qw( :utf8 :std ); 182use warnings; 183BEGIN { eval "sub foo (@\x{30cb}) {}"; } 184EXPECT 185Prototype after '@' for main::foo : @\x{30cb} at (eval 1) line 1. 186Illegal character in prototype for main::foo : @\x{30cb} at (eval 1) line 1. 187######## 188use warnings; 189sub f ([); 190sub f :prototype([) 191EXPECT 192Missing ']' in prototype for main::f : [ at - line 2. 193Missing ']' in prototype for main::f : [ at - line 3. 194######## 195use warnings; 196package bar { sub bar { eval q"sub foo ([)" } } 197bar::bar 198EXPECT 199Missing ']' in prototype for bar::foo : [ at (eval 1) line 1. 200######## 201# toke.c 202$a =~ m/$foo/eq; 203$a =~ s/$foo/fool/seq; 204 205EXPECT 206OPTION fatal 207Unknown regexp modifier "/e" at - line 2, near "=~ " 208Unknown regexp modifier "/q" at - line 2, near "=~ " 209Unknown regexp modifier "/q" at - line 3, near "=~ " 210Execution of - aborted due to compilation errors. 211######## 212# toke.c 213use utf8; 214use open qw( :utf8 :std ); 215$a =~ m/$foo/eネq; 216$a =~ s/$foo/fool/seネq; 217 218EXPECT 219OPTION fatal 220Unknown regexp modifier "/e" at - line 4, near "=~ " 221Unknown regexp modifier "/ネ" at - line 4, near "=~ " 222Unknown regexp modifier "/q" at - line 4, near "=~ " 223Unknown regexp modifier "/ネ" at - line 5, near "=~ " 224Unknown regexp modifier "/q" at - line 5, near "=~ " 225Execution of - aborted due to compilation errors. 226######## 227# toke.c 228use warnings 'syntax' ; 229s/(abc)/\1/; 230no warnings 'syntax' ; 231s/(abc)/\1/; 232EXPECT 233\1 better written as $1 at - line 3. 234######## 235# toke.c 236use warnings 'semicolon' ; 237$a = 1 238&time ; 239no warnings 'semicolon' ; 240$a = 1 241&time ; 242EXPECT 243Semicolon seems to be missing at - line 3. 244######## 245# toke.c 246use warnings 'syntax' ; 247my $a =+ 2 ; 248$a =- 2 ; 249$a =* 2 ; 250$a =% 2 ; 251$a =& 2 ; 252$a =. 2 ; 253$a =^ 2 ; 254$a =| 2 ; 255$a =< 2 ; 256$a =/ 2 ; 257EXPECT 258Reversed += operator at - line 3. 259Reversed -= operator at - line 4. 260Reversed *= operator at - line 5. 261Reversed %= operator at - line 6. 262Reversed &= operator at - line 7. 263Reversed .= operator at - line 8. 264syntax error at - line 8, near "=." 265Execution of - aborted due to compilation errors. 266######## 267# toke.c 268no warnings 'syntax' ; 269my $a =+ 2 ; 270$a =- 2 ; 271$a =* 2 ; 272$a =% 2 ; 273$a =& 2 ; 274$a =. 2 ; 275$a =^ 2 ; 276$a =| 2 ; 277$a =< 2 ; 278$a =/ 2 ; 279EXPECT 280syntax error at - line 8, near "=." 281Execution of - aborted due to compilation errors. 282######## 283# toke.c 284use warnings 'syntax' ; 285my $a = $a[1,2] ; 286no warnings 'syntax' ; 287my $a = $a[1,2] ; 288EXPECT 289Multidimensional syntax $a[1,2] not supported at - line 3. 290######## 291# toke.c 292use warnings 'syntax' ; 293sub fred {} ; $SIG{TERM} = fred; 294no warnings 'syntax' ; 295$SIG{TERM} = fred; 296EXPECT 297You need to quote "fred" at - line 3. 298######## 299# toke.c 300use utf8; 301use open qw( :utf8 :std ); 302use warnings 'syntax' ; 303sub frèd {} ; $SIG{TERM} = frèd; 304no warnings 'syntax' ; 305$SIG{TERM} = frèd; 306EXPECT 307You need to quote "frèd" at - line 5. 308######## 309# toke.c 310use utf8; 311use open qw( :utf8 :std ); 312use warnings 'syntax' ; 313sub ふれど {} ; $SIG{TERM} = ふれど; 314no warnings 'syntax' ; 315$SIG{TERM} = ふれど; 316EXPECT 317You need to quote "ふれど" at - line 5. 318######## 319# toke.c 320use warnings 'syntax' ; 321$_ = "ab" ; 322s/(ab)/\1/e; 323s//\(2)/e; # should be exempt 324s/${\2}//; # same here 325()="${\2}"; # metoo 326no warnings 'syntax' ; 327$_ = "ab" ; 328s/(ab)/\1/e; 329EXPECT 330Can't use \1 to mean $1 in expression at - line 4. 331######## 332# toke.c 333use warnings 'reserved' ; 334$a = abc; 335$a = { def 336 337=> 1 }; 338no warnings 'reserved' ; 339$a = abc; 340EXPECT 341Unquoted string "abc" may clash with future reserved word at - line 3. 342######## 343# toke.c 344use warnings 'qw' ; 345@a = qw(a, b, c) ; 346no warnings 'qw' ; 347@a = qw(a, b, c) ; 348EXPECT 349Possible attempt to separate words with commas at - line 3. 350######## 351# toke.c 352use warnings 'qw' ; 353@a = qw(a b c # #) ; 354no warnings 'qw' ; 355@a = qw(a b c # #) ; 356EXPECT 357Possible attempt to put comments in qw() list at - line 3. 358######## 359# toke.c 360use warnings 'qw' ; 361@a = qw(a, b, c # #) ; 362no warnings 'qw' ; 363@a = qw(a, b, c # #) ; 364EXPECT 365Possible attempt to separate words with commas at - line 3. 366Possible attempt to put comments in qw() list at - line 3. 367######## 368# toke.c 369use warnings 'syntax' ; 370print (""); 371print ("") and $x = 1; 372print ("") or die; 373print ("") // die; 374print (1+2) * 3 if 0; # only this one should warn 375print (1+2) if 0; 376EXPECT 377print (...) interpreted as function at - line 7. 378######## 379# toke.c 380no warnings 'syntax' ; 381print ("") 382EXPECT 383 384######## 385# toke.c 386use warnings 'syntax' ; 387printf (""); 388printf ("") . ''; 389EXPECT 390printf (...) interpreted as function at - line 4. 391######## 392# toke.c 393no warnings 'syntax' ; 394printf ("") 395EXPECT 396 397######## 398# toke.c 399use warnings 'syntax' ; 400sort (""); 401sort ("") . ''; 402EXPECT 403sort (...) interpreted as function at - line 4. 404######## 405# toke.c 406no warnings 'syntax' ; 407sort ("") 408EXPECT 409 410######## 411@foo::bar = 1..3; 412() = "$foo'bar"; 413() = "@foo'bar"; 414() = "$#foo'bar"; 415use warnings 'syntax'; 416() = "$foo'bar"; 417() = "@foo'bar"; 418() = "$#foo'bar"; 419no warnings 'syntax', 'deprecated' ; 420() = "$foo'bar"; 421() = "@foo'bar"; 422() = "$#foo'bar"; 423EXPECT 424Old package separator used in string at - line 2. 425 (Did you mean "$foo\'bar" instead?) 426Old package separator used in string at - line 3. 427 (Did you mean "@foo\'bar" instead?) 428Old package separator used in string at - line 4. 429 (Did you mean "$#foo\'bar" instead?) 430Old package separator used in string at - line 6. 431 (Did you mean "$foo\'bar" instead?) 432Old package separator used in string at - line 7. 433 (Did you mean "@foo\'bar" instead?) 434Old package separator used in string at - line 8. 435 (Did you mean "$#foo\'bar" instead?) 436######## 437use warnings 'syntax'; use utf8; 438@fooл::barл = 1..3; 439() = "$fooл'barл"; 440() = "@fooл'barл"; 441() = "$#fooл'barл"; 442no warnings 'syntax', 'deprecated' ; 443() = "$fooл'barл"; 444() = "@fooл'barл"; 445() = "$#fooл'barл"; 446EXPECT 447Old package separator used in string at - line 3. 448 (Did you mean "$fooл\'barл" instead?) 449Old package separator used in string at - line 4. 450 (Did you mean "@fooл\'barл" instead?) 451Old package separator used in string at - line 5. 452 (Did you mean "$#fooл\'barл" instead?) 453######## 454# NAME deprecation of ' in names 455sub foo'bar { 1 } 456$a'b = 1; 457@a'c = (); 458%a'd = (); 459package a'e; 460EXPECT 461Old package separator "'" deprecated at - line 1. 462Old package separator "'" deprecated at - line 2. 463Old package separator "'" deprecated at - line 3. 464Old package separator "'" deprecated at - line 4. 465Old package separator "'" deprecated at - line 5. 466######## 467# toke.c 468use warnings 'ambiguous' ; 469$a = ${time[2]}; 470no warnings 'ambiguous' ; 471$a = ${time[2]}; 472EXPECT 473Ambiguous use of ${time[...]} resolved to $time[...] at - line 3. 474######## 475# toke.c 476use warnings 'ambiguous' ; 477$a = ${time{2}}; 478EXPECT 479Ambiguous use of ${time{...}} resolved to $time{...} at - line 3. 480######## 481# toke.c 482use warnings 'ambiguous' ; 483$a = ${ 484 485 time 486 {2} 487}; 488warn "after"; 489EXPECT 490Ambiguous use of ${time{...}} resolved to $time{...} at - line 5. 491after at - line 8. 492######## 493# toke.c 494use warnings 'ambiguous' ; 495$a = ${ 496 497time[2] 498 499}; 500$a = ${ 501 502time 503 [2] 504 505}; 506warn "after"; 507EXPECT 508Ambiguous use of ${time[...]} resolved to $time[...] at - line 5. 509Ambiguous use of ${time[...]} resolved to $time[...] at - line 10. 510after at - line 14. 511######## 512# toke.c 513no warnings 'ambiguous' ; 514$a = ${time{2}}; 515EXPECT 516 517######## 518# toke.c 519use warnings 'ambiguous' ; 520$a = ${time} ; 521$a = @{time} ; 522$a = $#{time} ; # This one is special cased in toke.c 523$a = %{time} ; 524$a = *{time} ; 525$a = defined &{time} ; # To avoid calling &::time 526no warnings 'ambiguous' ; 527$a = ${time} ; 528$a = @{time} ; 529$a = $#{time} ; # This one is special cased in toke.c 530$a = %{time} ; 531$a = *{time} ; 532$a = defined &{time} ; # To avoid calling &::time 533EXPECT 534Ambiguous use of ${time} resolved to $time at - line 3. 535Ambiguous use of @{time} resolved to @time at - line 4. 536Ambiguous use of @{time} resolved to @time at - line 5. 537Ambiguous use of %{time} resolved to %time at - line 6. 538Ambiguous use of *{time} resolved to *time at - line 7. 539Ambiguous use of &{time} resolved to &time at - line 8. 540######## 541# toke.c 542use warnings 'ambiguous' ; 543$a = ${ 544time 545} ; 546$a = @{ 547time 548} ; 549$a = $#{ 550time 551} ; 552$a = %{ 553time 554} ; 555$a = *{ 556time 557} ; 558$a = defined &{ 559time 560 561 562} ; 563warn "last"; 564EXPECT 565Ambiguous use of ${time} resolved to $time at - line 4. 566Ambiguous use of @{time} resolved to @time at - line 7. 567Ambiguous use of @{time} resolved to @time at - line 10. 568Ambiguous use of %{time} resolved to %time at - line 13. 569Ambiguous use of *{time} resolved to *time at - line 16. 570Ambiguous use of &{time} resolved to &time at - line 19. 571last at - line 23. 572######## 573# toke.c 574use warnings 'ambiguous' ; 575sub fred {} 576$a = ${fred} ; 577no warnings 'ambiguous' ; 578$a = ${fred} ; 579EXPECT 580Ambiguous use of ${fred} resolved to $fred at - line 4. 581######## 582# toke.c 583use warnings 'syntax' ; 584$a = _123; print "$a\n"; #( 3 string) 585$a = 1_23; print "$a\n"; 586$a = 12_3; print "$a\n"; 587$a = 123_; print "$a\n"; # 6 588$a = _+123; print "$a\n"; # 7 string) 589$a = +_123; print "$a\n"; #( 8 string) 590$a = +1_23; print "$a\n"; 591$a = +12_3; print "$a\n"; 592$a = +123_; print "$a\n"; # 11 593$a = _-123; print "$a\n"; #(12 string) 594$a = -_123; print "$a\n"; #(13 string) 595$a = -1_23; print "$a\n"; 596$a = -12_3; print "$a\n"; 597$a = -123_; print "$a\n"; # 16 598$a = 123._456; print "$a\n"; # 17 599$a = 123.4_56; print "$a\n"; 600$a = 123.45_6; print "$a\n"; 601$a = 123.456_; print "$a\n"; # 20 602$a = +123._456; print "$a\n"; # 21 603$a = +123.4_56; print "$a\n"; 604$a = +123.45_6; print "$a\n"; 605$a = +123.456_; print "$a\n"; # 24 606$a = -123._456; print "$a\n"; # 25 607$a = -123.4_56; print "$a\n"; 608$a = -123.45_6; print "$a\n"; 609$a = -123.456_; print "$a\n"; # 28 610$a = 123.456E_12; printf("%.0f\n", $a); # 29 611$a = 123.456E1_2; printf("%.0f\n", $a); 612$a = 123.456E12_; printf("%.0f\n", $a); # 31 613$a = 123.456E_+12; printf("%.0f\n", $a); # 32 614$a = 123.456E+_12; printf("%.0f\n", $a); # 33 615$a = 123.456E+1_2; printf("%.0f\n", $a); 616$a = 123.456E+12_; printf("%.0f\n", $a); # 35 617$a = 123.456E_-12; print "$a\n"; # 36 618$a = 123.456E-_12; print "$a\n"; # 37 619$a = 123.456E-1_2; print "$a\n"; 620$a = 123.456E-12_; print "$a\n"; # 39 621$a = 1__23; print "$a\n"; # 40 622$a = 12.3__4; print "$a\n"; # 41 623$a = 12.34e1__2; printf("%.0f\n", $a); # 42 624no warnings 'syntax' ; 625$a = _123; print "$a\n"; 626$a = 1_23; print "$a\n"; 627$a = 12_3; print "$a\n"; 628$a = 123_; print "$a\n"; 629$a = _+123; print "$a\n"; 630$a = +_123; print "$a\n"; 631$a = +1_23; print "$a\n"; 632$a = +12_3; print "$a\n"; 633$a = +123_; print "$a\n"; 634$a = _-123; print "$a\n"; 635$a = -_123; print "$a\n"; 636$a = -1_23; print "$a\n"; 637$a = -12_3; print "$a\n"; 638$a = -123_; print "$a\n"; 639$a = 123._456; print "$a\n"; 640$a = 123.4_56; print "$a\n"; 641$a = 123.45_6; print "$a\n"; 642$a = 123.456_; print "$a\n"; 643$a = +123._456; print "$a\n"; 644$a = +123.4_56; print "$a\n"; 645$a = +123.45_6; print "$a\n"; 646$a = +123.456_; print "$a\n"; 647$a = -123._456; print "$a\n"; 648$a = -123.4_56; print "$a\n"; 649$a = -123.45_6; print "$a\n"; 650$a = -123.456_; print "$a\n"; 651$a = 123.456E_12; printf("%.0f\n", $a); 652$a = 123.456E1_2; printf("%.0f\n", $a); 653$a = 123.456E12_; printf("%.0f\n", $a); 654$a = 123.456E_+12; printf("%.0f\n", $a); 655$a = 123.456E+_12; printf("%.0f\n", $a); 656$a = 123.456E+1_2; printf("%.0f\n", $a); 657$a = 123.456E+12_; printf("%.0f\n", $a); 658$a = 123.456E_-12; print "$a\n"; 659$a = 123.456E-_12; print "$a\n"; 660$a = 123.456E-1_2; print "$a\n"; 661$a = 123.456E-12_; print "$a\n"; 662$a = 1__23; print "$a\n"; 663$a = 12.3__4; print "$a\n"; 664$a = 12.34e1__2; printf("%.0f\n", $a); 665EXPECT 666OPTIONS regex 667Misplaced _ in number at - line 6. 668Misplaced _ in number at - line 11. 669Misplaced _ in number at - line 16. 670Misplaced _ in number at - line 17. 671Misplaced _ in number at - line 20. 672Misplaced _ in number at - line 21. 673Misplaced _ in number at - line 24. 674Misplaced _ in number at - line 25. 675Misplaced _ in number at - line 28. 676Misplaced _ in number at - line 29. 677Misplaced _ in number at - line 31. 678Misplaced _ in number at - line 32. 679Misplaced _ in number at - line 33. 680Misplaced _ in number at - line 35. 681Misplaced _ in number at - line 36. 682Misplaced _ in number at - line 37. 683Misplaced _ in number at - line 39. 684Misplaced _ in number at - line 40. 685Misplaced _ in number at - line 41. 686Misplaced _ in number at - line 42. 687_123 688123 689123 690123 691123 692_123 693123 694123 695123 696-123 697-_123 698-123 699-123 700-123 701123.456 702123.456 703123.456 704123.456 705123.456 706123.456 707123.456 708123.456 709-123.456 710-123.456 711-123.456 712-123.456 713123456000000000 714123456000000000 715123456000000000 716123456000000000 717123456000000000 718123456000000000 719123456000000000 7201.23456e-0?10 7211.23456e-0?10 7221.23456e-0?10 7231.23456e-0?10 724123 72512.34 72612340000000000 727_123 728123 729123 730123 731123 732_123 733123 734123 735123 736-123 737-_123 738-123 739-123 740-123 741123.456 742123.456 743123.456 744123.456 745123.456 746123.456 747123.456 748123.456 749-123.456 750-123.456 751-123.456 752-123.456 753123456000000000 754123456000000000 755123456000000000 756123456000000000 757123456000000000 758123456000000000 759123456000000000 7601.23456e-0?10 7611.23456e-0?10 7621.23456e-0?10 7631.23456e-0?10 764123 76512.34 76612340000000000 767######## 768# toke.c 769use warnings 'syntax'; 770$a = 1_; print "$a\n"; 771$a = 01_; print "$a\n"; 772$a = 0_; print "$a\n"; 773$a = 0x1_; print "$a\n"; 774$a = 1.2_; print "$a\n"; 775$a = 1._2; print "$a\n"; 776$a = 1._; print "$a\n"; 777EXPECT 778Misplaced _ in number at - line 3. 779Misplaced _ in number at - line 4. 780Misplaced _ in number at - line 5. 781Misplaced _ in number at - line 6. 782Misplaced _ in number at - line 7. 783Misplaced _ in number at - line 8. 784Misplaced _ in number at - line 9. 7851 7861 7870 7881 7891.2 7901.2 7911 792######## 793# toke.c 794use warnings 'bareword' ; 795#line 25 "bar" 796$a = FRED:: ; 797no warnings 'bareword' ; 798#line 25 "bar" 799$a = FRED:: ; 800EXPECT 801Bareword "FRED::" refers to nonexistent package at bar line 25. 802######## 803# toke.c 804use utf8; 805use open qw( :utf8 :std ); 806use warnings 'bareword' ; 807#line 25 "bar" 808$a = FRÈD:: ; 809no warnings 'bareword' ; 810#line 25 "bar" 811$a = FRÈD:: ; 812EXPECT 813Bareword "FRÈD::" refers to nonexistent package at bar line 25. 814######## 815# toke.c 816use utf8; 817use open qw( :utf8 :std ); 818use warnings 'bareword' ; 819#line 25 "bar" 820$a = ϞϞϞ:: ; 821no warnings 'bareword' ; 822#line 25 "bar" 823$a = ϞϞϞ:: ; 824EXPECT 825Bareword "ϞϞϞ::" refers to nonexistent package at bar line 25. 826######## 827# toke.c 828use warnings 'ambiguous' ; 829sub time {} 830my $a = time() ; 831no warnings 'ambiguous' ; 832my $b = time() ; 833EXPECT 834Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4. 835######## 836# toke.c 837use warnings ; 838eval <<'EOE'; 839# line 30 "foo" 840warn "yelp"; 841{ 842 $_ = " \x{123} " ; 843} 844EOE 845EXPECT 846yelp at foo line 30. 847######## 848# toke.c 849my $a = rand + 4 ; 850$a = rand *^H ; 851$a = rand $^H ; 852EXPECT 853Warning: Use of "rand" without parentheses is ambiguous at - line 2. 854######## 855# toke.c 856$^W = 0 ; 857my $a = rand + 4 ; 858{ 859 no warnings 'ambiguous' ; 860 $a = rand + 4 ; 861 use warnings 'ambiguous' ; 862 $a = rand + 4 ; 863} 864$a = rand + 4 ; 865EXPECT 866Warning: Use of "rand" without parentheses is ambiguous at - line 3. 867Warning: Use of "rand" without parentheses is ambiguous at - line 8. 868Warning: Use of "rand" without parentheses is ambiguous at - line 10. 869######## 870# [perl #97110] 871sub myrand(;$) { } 872sub whatever($) { } 873my $a = myrand + 4 ; 874my $b = whatever + 4 ; 875EXPECT 876Warning: Use of "myrand" without parentheses is ambiguous at - line 4. 877######## 878# toke.c 879use warnings "ambiguous"; 880print for keys %+; # should not warn 881EXPECT 882######## 883# toke.c [This does not warn any more.] 884sub fred {}; 885-fred ; 886sub hank : lvalue {$_} 887--hank; # This should *not* warn [perl #77240] 888EXPECT 889######## 890# toke.c [This does not warn any more.] 891$^W = 0 ; 892sub fred {} ; 893-fred ; 894{ 895 no warnings 'ambiguous' ; 896 -fred ; 897 use warnings 'ambiguous' ; 898 -fred ; 899} 900-fred ; 901EXPECT 902######## 903# toke.c [This does not warn any more.] 904use utf8; 905use open qw( :utf8 :std ); 906sub frèd {}; 907-frèd ; 908EXPECT 909######## 910# toke.c [This does not warn any more.] 911$^W = 0 ; 912use utf8; 913use open qw( :utf8 :std ); 914sub frèd {} ; 915-frèd ; 916{ 917 no warnings 'ambiguous' ; 918 -frèd ; 919 use warnings 'ambiguous' ; 920 -frèd ; 921} 922-frèd ; 923EXPECT 924######## 925# toke.c [This does not warn any more.] 926use utf8; 927use open qw( :utf8 :std ); 928sub ᒍᒘᒊ {}; 929-ᒍᒘᒊ ; 930EXPECT 931######## 932# toke.c [This does not warn any more.] 933$^W = 0 ; 934use utf8; 935use open qw( :utf8 :std ); 936sub ᒍᒘᒊ {} ; 937-ᒍᒘᒊ ; 938{ 939 no warnings 'ambiguous' ; 940 -ᒍᒘᒊ ; 941 use warnings 'ambiguous' ; 942 -ᒍᒘᒊ ; 943} 944-ᒍᒘᒊ ; 945EXPECT 946######## 947# toke.c 948open FOO || time; 949open local *FOO; # should be ok 950EXPECT 951Precedence problem: open FOO should be open(FOO) at - line 2. 952######## 953# toke.c 954use utf8; 955use open qw( :utf8 :std ); 956open FÒÒ || time; 957EXPECT 958Precedence problem: open FÒÒ should be open(FÒÒ) at - line 4. 959######## 960# toke.c 961use utf8; 962use open qw( :utf8 :std ); 963open ᒍOO || time; 964EXPECT 965Precedence problem: open ᒍOO should be open(ᒍOO) at - line 4. 966######## 967# toke.c (and [perl #16184]) 968open FOO => "<&0"; close FOO; 969EXPECT 970######## 971# toke.c 972$^W = 0 ; 973open FOO || time; 974{ 975 no warnings 'precedence' ; 976 open FOO || time; 977 use warnings 'precedence' ; 978 open FOO || time; 979} 980open FOO || time; 981open Foo::BAR; # this should not warn 982EXPECT 983Precedence problem: open FOO should be open(FOO) at - line 3. 984Precedence problem: open FOO should be open(FOO) at - line 8. 985Precedence problem: open FOO should be open(FOO) at - line 10. 986######## 987# toke.c 988$^W = 0 ; 989use utf8; 990use open qw( :utf8 :std ); 991open FÒÒ || time; 992{ 993 no warnings 'precedence' ; 994 open FÒÒ || time; 995 use warnings 'precedence' ; 996 open FÒÒ || time; 997} 998open FÒÒ || time; 999EXPECT 1000Precedence problem: open FÒÒ should be open(FÒÒ) at - line 5. 1001Precedence problem: open FÒÒ should be open(FÒÒ) at - line 10. 1002Precedence problem: open FÒÒ should be open(FÒÒ) at - line 12. 1003######## 1004# toke.c 1005use utf8; 1006use open qw( :utf8 :std ); 1007$^W = 0 ; 1008open ᒍÒÒ || time; 1009{ 1010 no warnings 'precedence' ; 1011 open ᒍÒÒ || time; 1012 use warnings 'precedence' ; 1013 open ᒍÒÒ || time; 1014} 1015open ᒍÒÒ || time; 1016EXPECT 1017Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 5. 1018Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 10. 1019Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 12. 1020######## 1021# toke.c 1022$^W = 0 ; 1023*foo *foo ; 1024{ 1025 no warnings 'ambiguous' ; 1026 *foo *foo ; 1027 use warnings 'ambiguous' ; 1028 *foo *foo ; 1029} 1030*foo *foo ; 1031# These should not warn [perl #117535]: 1032foo**foo ; 1033no warnings 'deprecated'; 1034sort $*foo ; 1035sort $ *foo ; 1036EXPECT 1037Operator or semicolon missing before *foo at - line 3. 1038Ambiguous use of * resolved as operator * at - line 3. 1039Operator or semicolon missing before *foo at - line 8. 1040Ambiguous use of * resolved as operator * at - line 8. 1041Operator or semicolon missing before *foo at - line 10. 1042Ambiguous use of * resolved as operator * at - line 10. 1043$* is no longer supported as of Perl 5.30 at - line 14. 1044######## 1045# toke.c 1046$^W = 0 ; 1047%foo %foo ; 1048{ 1049 no warnings 'ambiguous' ; 1050 %foo %foo ; 1051 use warnings 'ambiguous' ; 1052 %foo %foo ; 1053} 1054%foo %foo ; 1055# This should not produce ambiguity warnings [perl #117535]: 1056sort $%foo ; 1057sort $ %foo ; 1058EXPECT 1059Operator or semicolon missing before %foo at - line 3. 1060Ambiguous use of % resolved as operator % at - line 3. 1061Operator or semicolon missing before %foo at - line 8. 1062Ambiguous use of % resolved as operator % at - line 8. 1063Operator or semicolon missing before %foo at - line 10. 1064Ambiguous use of % resolved as operator % at - line 10. 1065Bareword found where operator expected (Missing operator before "foo"?) at - line 12, near "$%foo" 1066Bareword found where operator expected (Missing operator before "foo"?) at - line 13, near "$ %foo" 1067Illegal modulus zero at - line 3. 1068######## 1069# toke.c 1070$^W = 0 ; 1071&foo &foo ; 1072{ 1073 no warnings 'ambiguous' ; 1074 &foo &foo ; 1075 use warnings 'ambiguous' ; 1076 &foo &foo ; 1077} 1078&foo &foo ; 1079# These should not warn produce ambiguity warnings [perl #76910]: 1080foo&&foo ; 1081sort $&foo ; 1082sort $ &foo ; 1083EXPECT 1084Operator or semicolon missing before &foo at - line 3. 1085Ambiguous use of & resolved as operator & at - line 3. 1086Operator or semicolon missing before &foo at - line 8. 1087Ambiguous use of & resolved as operator & at - line 8. 1088Operator or semicolon missing before &foo at - line 10. 1089Ambiguous use of & resolved as operator & at - line 10. 1090Bareword found where operator expected (Missing operator before "foo"?) at - line 13, near "$&foo" 1091Bareword found where operator expected (Missing operator before "foo"?) at - line 14, near "$ &foo" 1092Undefined subroutine &main::foo called at - line 3. 1093######## 1094# toke.c 1095use utf8; 1096use open qw( :utf8 :std ); 1097$^W = 0 ; 1098*foo *foo ; 1099{ 1100 no warnings 'ambiguous' ; 1101 *foo *foo ; 1102 use warnings 'ambiguous' ; 1103 *foo *foo ; 1104} 1105*foo *foo ; 1106EXPECT 1107Operator or semicolon missing before *foo at - line 5. 1108Ambiguous use of * resolved as operator * at - line 5. 1109Operator or semicolon missing before *foo at - line 10. 1110Ambiguous use of * resolved as operator * at - line 10. 1111Operator or semicolon missing before *foo at - line 12. 1112Ambiguous use of * resolved as operator * at - line 12. 1113######## 1114# toke.c 1115use warnings 'misc' ; 1116my $a = "\m" ; 1117no warnings 'misc' ; 1118$a = "\m" ; 1119EXPECT 1120Unrecognized escape \m passed through at - line 3. 1121######## 1122# toke.c 1123use warnings 'misc' ; 1124my $a = "abcd\E" ; 1125no warnings 'misc' ; 1126$a = "abcd\E" ; 1127EXPECT 1128Useless use of \E at - line 3. 1129######## 1130# toke.c 1131use feature 'postderef_qq'; 1132(\$_)->$*; 1133"$_->$*"; 1134(\$_)->$*; 1135"$_->$*"; 1136EXPECT 1137######## 1138# toke.c 1139use warnings 'portable' ; 1140my $a = 0b011111111111111111111111111111110 ; 1141 $a = 0b011111111111111111111111111111111 ; 1142 $a = 0b111111111111111111111111111111111 ; 1143 $a = 0x0fffffffe ; 1144 $a = 0x0ffffffff ; 1145 $a = 0x1ffffffff ; 1146 $a = 0037777777776 ; 1147 $a = 0037777777777 ; 1148 $a = 0047777777777 ; 1149no warnings 'portable' ; 1150 $a = 0b011111111111111111111111111111110 ; 1151 $a = 0b011111111111111111111111111111111 ; 1152 $a = 0b111111111111111111111111111111111 ; 1153 $a = 0x0fffffffe ; 1154 $a = 0x0ffffffff ; 1155 $a = 0x1ffffffff ; 1156 $a = 0037777777776 ; 1157 $a = 0037777777777 ; 1158 $a = 0047777777777 ; 1159EXPECT 1160Binary number > 0b11111111111111111111111111111111 non-portable at - line 5. 1161Hexadecimal number > 0xffffffff non-portable at - line 8. 1162Octal number > 037777777777 non-portable at - line 11. 1163######## 1164# toke.c 1165use warnings 'overflow' ; 1166my $a = 0b011111111111111111111111111111110 ; 1167 $a = 0b011111111111111111111111111111111 ; 1168 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ; 1169 $a = 0x0fffffffe ; 1170 $a = 0x0ffffffff ; 1171 $a = 0x10000000000000000 ; 1172 $a = 0037777777776 ; 1173 $a = 0037777777777 ; 1174 $a = 002000000000000000000000; 1175no warnings 'overflow' ; 1176 $a = 0b011111111111111111111111111111110 ; 1177 $a = 0b011111111111111111111111111111111 ; 1178 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ; 1179 $a = 0x0fffffffe ; 1180 $a = 0x0ffffffff ; 1181 $a = 0x10000000000000000 ; 1182 $a = 0037777777776 ; 1183 $a = 0037777777777 ; 1184 $a = 002000000000000000000000; 1185EXPECT 1186Integer overflow in binary number at - line 5. 1187Integer overflow in hexadecimal number at - line 8. 1188Integer overflow in octal number at - line 11. 1189######## 1190# toke.c 1191use warnings 'ambiguous'; 1192"@mjd_previously_unused_array"; 1193no warnings 'ambiguous'; 1194"@mjd_previously_unused_array2"; 1195EXPECT 1196Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3. 1197######## 1198# toke.c 1199use utf8; 1200use open qw( :utf8 :std ); 1201use warnings 'ambiguous'; 1202"@mjd_previously_unused_àrray"; 1203no warnings 'ambiguous'; 1204"@mjd_previously_unused_àrray2"; 1205EXPECT 1206Possible unintended interpolation of @mjd_previously_unused_àrray in string at - line 5. 1207######## 1208# toke.c 1209use utf8; 1210use open qw( :utf8 :std ); 1211use warnings 'ambiguous'; 1212"@mjd_previously_unused_ぁrrぁy"; 1213no warnings 'ambiguous'; 1214"@mjd_previously_unused_ぁrrぁy2"; 1215EXPECT 1216Possible unintended interpolation of @mjd_previously_unused_ぁrrぁy in string at - line 5. 1217######## 1218-w 1219# toke.c 1220$_ = "@DB::args"; 1221EXPECT 1222######## 1223# toke.c 1224# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com 1225use warnings 'regexp'; 1226"foo" =~ /foo/c; 1227"foo" =~ /foo/cg; 1228no warnings 'regexp'; 1229"foo" =~ /foo/c; 1230"foo" =~ /foo/cg; 1231EXPECT 1232Use of /c modifier is meaningless without /g at - line 4. 1233######## 1234# toke.c 1235# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com 1236use warnings 'regexp'; 1237$_ = "ab" ; 1238s/ab/ab/c; 1239s/ab/ab/cg; 1240no warnings 'regexp'; 1241s/ab/ab/c; 1242s/ab/ab/cg; 1243EXPECT 1244Use of /c modifier is meaningless in s/// at - line 5. 1245Use of /c modifier is meaningless in s/// at - line 6. 1246######## 1247-wa 1248# toke.c 1249# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings 1250print "@F\n"; 1251EXPECT 1252 1253######## 1254-w 1255# toke.c 1256# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings 1257print "@F\n"; 1258EXPECT 1259Possible unintended interpolation of @F in string at - line 4. 1260Name "main::F" used only once: possible typo at - line 4. 1261######## 1262-wa 1263# toke.c 1264# 20020414 mjd-perl-patch+@plover.com 1265EXPECT 1266 1267######## 1268# toke.c 1269# 20020414 mjd-perl-patch+@plover.com 1270# In 5.7.3, this emitted "Possible unintended interpolation" warnings 1271use warnings 'ambiguous'; 1272$s = "(@-)(@+)"; 1273EXPECT 1274 1275######## 1276# toke.c 1277# mandatory warning 1278eval q/if ($a) { } elseif ($b) { }/; 1279no warnings "syntax"; 1280eval q/if ($a) { } elseif ($b) { }/; 1281EXPECT 1282elseif should be elsif at (eval 1) line 1. 1283######## 1284# toke.c 1285# mandatory warning 1286eval q/5 6/; 1287no warnings "syntax"; 1288eval q/5 6/; 1289EXPECT 1290Number found where operator expected (Missing operator before "6"?) at (eval 1) line 1, near "5 6" 1291######## 1292# toke.c 1293use warnings "syntax"; no warnings "deprecated"; 1294$_ = $a = 1; 1295$a !=~ /1/; 1296$a !=~ m#1#; 1297$a !=~/1/; 1298$a !=~ y/1//; 1299$a !=~ tr/1//; 1300$a !=~ s/1//; 1301$a != ~/1/; 1302no warnings "syntax"; 1303$a !=~ /1/; 1304$a !=~ m#1#; 1305$a !=~/1/; 1306$a !=~ y/1//; 1307$a !=~ tr/1//; 1308$a !=~ s/1//; 1309EXPECT 1310!=~ should be !~ at - line 4. 1311!=~ should be !~ at - line 5. 1312!=~ should be !~ at - line 6. 1313!=~ should be !~ at - line 7. 1314!=~ should be !~ at - line 8. 1315!=~ should be !~ at - line 9. 1316######## 1317# toke.c 1318use warnings "syntax"; 1319sub proto_after_array(@$); 1320sub proto_after_arref(\@$); 1321sub proto_after_arref2(\[@$]); 1322sub proto_after_arref3(\[@$]_); 1323sub proto_after_hash(%$); 1324sub proto_after_hashref(\%$); 1325sub proto_after_hashref2(\[%$]); 1326sub underscore_last_pos($_); 1327sub underscore2($_;$); 1328sub underscore_fail($_$); sub underscore_fail2 : prototype($_$); 1329sub underscore_after_at(@_); 1330our sub hour (@$); 1331my sub migh (@$); 1332use feature 'state'; 1333state sub estate (@$); 1334package other; 1335sub hour (@$); 1336sub migh (@$); 1337sub estate (@$); 1338no warnings "syntax"; 1339sub proto_after_array(@$); 1340sub proto_after_hash(%$); 1341sub underscore_fail($_$); 1342EXPECT 1343Prototype after '@' for main::proto_after_array : @$ at - line 3. 1344Prototype after '%' for main::proto_after_hash : %$ at - line 7. 1345Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12. 1346Illegal character after '_' in prototype for main::underscore_fail2 : $_$ at - line 12. 1347Prototype after '@' for main::underscore_after_at : @_ at - line 13. 1348Prototype after '@' for hour : @$ at - line 14. 1349Prototype after '@' for migh : @$ at - line 15. 1350Prototype after '@' for estate : @$ at - line 17. 1351Prototype after '@' for hour : @$ at - line 19. 1352Prototype after '@' for migh : @$ at - line 20. 1353Prototype after '@' for estate : @$ at - line 21. 1354######## 1355# toke.c 1356use warnings "ambiguous"; 1357"foo\nn" =~ /^foo$\n/; 1358"foo\nn" =~ /^foo${\}n/; 1359my $foo = qr/^foo$\n/; 1360my $bar = qr/^foo${\}n/; 1361no warnings "ambiguous"; 1362"foo\nn" =~ /^foo$\n/; 1363"foo\nn" =~ /^foo${\}n/; 1364my $foo = qr/^foo$\n/; 1365my $bar = qr/^foo${\}n/; 1366EXPECT 1367Possible unintended interpolation of $\ in regex at - line 3. 1368Possible unintended interpolation of $\ in regex at - line 5. 1369######## 1370# toke.c 1371use warnings 'syntax' ; 1372my $a = "\o"; 1373my $a = "\o{"; 1374my $a = "\o{}"; 1375no warnings 'syntax' ; 1376my $a = "\o"; 1377my $a = "\o{"; 1378my $a = "\o{}"; 1379EXPECT 1380Missing braces on \o{} at - line 3, within string 1381Missing right brace on \o{} at - line 4, within string 1382Empty \o{} at - line 5, within string 1383BEGIN not safe after errors--compilation aborted at - line 6. 1384######## 1385# toke.c 1386use warnings 'digit' ; 1387my $a = "\o{1238456}"; 1388no warnings 'digit' ; 1389my $a = "\o{1238456}"; 1390EXPECT 1391Non-octal character '8' terminates \o early. Resolved as "\o{123}" at - line 3. 1392######## 1393# toke.c 1394use warnings; 1395print ref ? "yes\n" : "no\n" foreach [], ''; # ? is unambiguosly an operator 1396EXPECT 1397yes 1398no 1399######## 1400# toke .c 1401use warnings; 1402$a =~ ?rand?; # ? is not a regex match 1403EXPECT 1404syntax error at - line 3, near "=~ ?" 1405Execution of - aborted due to compilation errors. 1406######## 1407# toke.c 1408BEGIN { 1409 if (ord('A') == 193) { 1410 print "SKIPPED\n# result varies depending on which ebcdic platform"; 1411 exit 0; 1412 } 1413} 1414use warnings; 1415$a = "\c,"; 1416$a = "\c`"; 1417no warnings 'syntax'; 1418$a = "\c,"; 1419$a = "\c`"; 1420EXPECT 1421"\c," is more clearly written simply as "l" at - line 9. 1422"\c`" is more clearly written simply as "\ " at - line 10. 1423######## 1424# toke.c 1425BEGIN { 1426 if (ord('A') == 193) { 1427 print "SKIPPED\n# test is ASCII-specific"; 1428 exit 0; 1429 } 1430} 1431use warnings; 1432my $a = "\c{ack}"; 1433EXPECT 1434OPTION fatal 1435Use ";" instead of "\c{" at - line 9, within string 1436Execution of - aborted due to compilation errors. 1437######## 1438# toke.c 1439BEGIN { 1440 if (ord('A') == 65) { 1441 print "SKIPPED\n# test is EBCDIC-specific"; 1442 exit 0; 1443 } 1444} 1445use warnings; 1446my $a = "\c{ack}"; 1447EXPECT 1448OPTION fatal 1449Sequence "\c{" invalid at - line 9, within string 1450Execution of - aborted due to compilation errors. 1451######## 1452# toke.c 1453my $a = "\câ"; 1454EXPECT 1455OPTION fatal 1456Character following "\c" must be printable ASCII at - line 2, within string 1457Execution of - aborted due to compilation errors. 1458######## 1459# toke.c 1460use warnings 'syntax' ; 1461my $a = qr/foo/du; 1462$a = qr/foo/lai; 1463$a = qr/foo/lil; 1464$a = qr/foo/aia; 1465$a = qr/foo/aaia; 1466no warnings 'syntax' ; 1467my $a = qr/foo/du; 1468EXPECT 1469Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= " 1470Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= " 1471Regexp modifier "/l" may not appear twice at - line 5, near "= " 1472Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= " 1473BEGIN not safe after errors--compilation aborted at - line 8. 1474######## 1475# toke.c 1476# [perl #4362] 1477eval "no warnings 'deprecated'; print q\xabfoo"; 1478if ($@ =~ /Can't find string terminator "\xab" anywhere before EOF/) { 1479 print "ok\n"; 1480} 1481else { 1482 print "not ok $@\n"; 1483} 1484EXPECT 1485ok 1486######## 1487# toke.c 1488use utf8; 1489use open qw( :utf8 :std ); 1490use warnings 'ambiguous' ; 1491sub frèd {} 1492$a = ${frèd} ; 1493no warnings 'ambiguous' ; 1494$a = ${frèd} ; 1495EXPECT 1496Ambiguous use of ${frèd} resolved to $frèd at - line 6. 1497######## 1498# toke.c 1499use utf8; 1500use open qw( :utf8 :std ); 1501use warnings 'ambiguous' ; 1502sub f렏 {} 1503$a = ${f렏} ; 1504no warnings 'ambiguous' ; 1505$a = ${f렏} ; 1506EXPECT 1507Ambiguous use of ${f렏} resolved to $f렏 at - line 6. 1508######## 1509# toke.c 1510use utf8; 1511use open qw( :utf8 :std ); 1512use warnings; 1513CORE::렏; 1514EXPECT 1515CORE::렏 is not a keyword at - line 5. 1516######## 1517# toke.c 1518# [perl #16249] 1519print ''; 1520eval this_method_is_fake (); 1521EXPECT 1522Undefined subroutine &main::this_method_is_fake called at - line 4. 1523######## 1524# toke.c 1525# [perl #107002] Erroneous ambiguity warnings 1526sub { # do not actually call require 1527 require a::b . 1; # These used to produce erroneous 1528 require a::b + 1; # ambiguity warnings. 1529} 1530EXPECT 1531######## 1532# toke.c 1533# [perl #113094], [perl #119101], since reverted so no warnings generated 1534use warnings; 1535print "aa" =~ m{^a\{1,2\}$}, "A\n"; 1536print "aa" =~ m{^a\x\{61\}$}, "B\n"; 1537print "a\\x{6F}" =~ m{^a\\x\{6F\}$}, "C\n"; 1538print "a\\o" =~ m{^a\\\x\{6F\}$}, "D\n"; 1539print "a\\\\x{6F}" =~ m{^a\\\\x\{6F\}$}, "E\n"; 1540print "a\\\\o" =~ m{^a\\\\\x\{6F\}$}, "F\n"; 1541print "aa" =~ m{^a{1,2}$}, "G\n"; 1542print "aq" =~ m[^a\[a-z\]$], "H\n"; 1543print "aq" =~ m(^a\(q\)$), "I\n"; 1544EXPECT 1545Non-hex character '\\' terminates \x early. Resolved as "\x00\\" in regex; marked by <-- HERE in m/^a\x <-- HERE \{61\}$/ at - line 5. 1546Non-hex character '\\' terminates \x early. Resolved as "\x00\\" in regex; marked by <-- HERE in m/^a\\\x <-- HERE \{6F\}$/ at - line 7. 1547Non-hex character '\\' terminates \x early. Resolved as "\x00\\" in regex; marked by <-- HERE in m/^a\\\\\x <-- HERE \{6F\}$/ at - line 9. 1548A 1549B 15501C 1551D 15521E 1553F 15541G 1555H 1556I 1557######## 1558# toke.c 1559#[perl #119123] disallow literal control character variables 1560*{ 1561 Foo 1562}; # shouldn't warn on {\n, even though \n is a control character 1563EXPECT 1564######## 1565# toke.c 1566# [perl #120288] -X at start of line gave spurious warning, where X is not 1567# a filetest operator 1568-a; 1569;-a; 1570EXPECT 1571######## 1572# toke.c 1573# [perl #124113] Compile-time warning with UTF8 variable in array index 1574use warnings; 1575use utf8; 1576my $ = 0; 1577my @array = (0); 1578my $v = $array[ 0 + $ ]; 1579 $v = $array[ $ + 0 ]; 1580EXPECT 1581######## 1582# toke.c 1583# Allow Unicode here doc boundaries 1584use warnings; 1585use utf8; 1586my $v = <<EnFraçais; 1587Comme ca! 1588EnFraçais 1589print $v; 1590EXPECT 1591Comme ca! 1592######## 1593# toke.c 1594# Fix 'Use of "..." without parentheses is ambiguous' warning for 1595# Unicode function names. If not under PERL_UNICODE, this will generate 1596# a "Wide character" warning 1597use utf8; 1598use warnings; 1599sub (;$) { return 0; } 1600my $v = - 5; 1601EXPECT 1602OPTION regex 1603(Wide character.*\n)?Warning: Use of "" without parentheses is ambiguous 1604######## 1605# RT #4346 Case 1: Warnings for print (...) 1606# TODO RT #4346: Warnings for print(...) are inconsistent 1607use warnings; 1608print ("((\n"); 1609print (">>\n"); 1610EXPECT 1611print (...) interpreted as function at - line 3. 1612print (...) interpreted as function at - line 4. 1613(( 1614>> 1615######## 1616# RT #4346 Case 2: Warnings for print (...) 1617use warnings; 1618print ("((\n"); 1619print (">>\n") 1620EXPECT 1621print (...) interpreted as function at - line 3. 1622print (...) interpreted as function at - line 4. 1623(( 1624>> 1625######## 1626# RT #4346 Case 3: Warnings for print (...) 1627# TODO RT #4346: Warnings for print(...) are inconsistent 1628use warnings; 1629print (">>\n"); 1630print ("((\n"); 1631EXPECT 1632print (...) interpreted as function at - line 3. 1633print (...) interpreted as function at - line 4. 1634>> 1635(( 1636######## 1637# RT #4346 Case 4: Warnings for print (...) 1638# TODO RT #4346: Warnings for print(...) are inconsistent 1639use warnings; 1640print (")\n"); 1641print ("))\n"); 1642EXPECT 1643print (...) interpreted as function at - line 3. 1644print (...) interpreted as function at - line 4. 1645) 1646)) 1647######## 1648# NAME Non-grapheme delimiters 1649BEGIN{ 1650 if (ord('A') == 193) { 1651 print "SKIPPED\n# ebcdic platforms generates different Malformed UTF-8 warnings."; 1652 exit 0; 1653 } 1654} 1655use utf8; 1656my $a = qr ̂foobar̂; 1657EXPECT 1658Use of unassigned code point or non-standalone grapheme for a delimiter is not allowed at - line 8, near "= " 1659Execution of - aborted due to compilation errors. 1660######## 1661# NAME [perl #130567] Assertion failure 1662BEGIN { 1663 if (ord('A') != 65) { 1664 print "SKIPPED\n# test is ASCII-specific"; 1665 exit 0; 1666 } 1667} 1668no warnings "uninitialized"; 1669$_= ""; 1670s//\3000/; 1671s//"\x{180};;s\221(*$@$`\241\275";/gee; 1672s//"s\221\302\302\302\302\302\302\302$@\241\275";/gee; 1673EXPECT 1674######## 1675# NAME [perl #130666] Assertion failure 1676no warnings "uninitialized"; 1677BEGIN{$^H=-1};my $l; s$0[$l] 1678EXPECT 1679######## 1680# NAME [perl #129036] Assertion failure 1681BEGIN{$0="";$^H=hex join""=>A00000}p? 1682EXPECT 1683OPTION fatal 1684syntax error at - line 1, at EOF 1685Execution of - aborted due to compilation errors. 1686######## 1687# NAME [perl #130655] 1688use utf8; 1689qw∘foo ∞ ♥ bar∘ 1690EXPECT 1691######## 1692# NAME [perl #134064] 1693BEGIN { 1694 if (ord('A') == 193) { 1695 print "SKIPPED\n# test is ASCII-specific, but could be extended to EBCDIC"; 1696 exit 0; 1697 } 1698} 1699use utf8; 1700$foo="m'\302'"; 1701eval $foo ; 1702print "The eval did not crash the program\n" 1703EXPECT 1704OPTION regex 1705Malformed UTF-8 character: .*non-continuation.* 1706The eval did not crash the program 1707######## 1708# NAME [perl #133850] print $fh $1 in s///e expression 1709use warnings; 1710my $fh = \*STDOUT; 1711$_ = "abc"; 1712s/(x)/ print $fh $1 /e; 1713EXPECT 1714######## 1715# NAME [perl #133850] side case 1716use warnings; 1717my $fh = \*STDOUT; 1718my $y = ""; 1719my $x = "${print $fh $y; \'x'}"; 1720EXPECT 1721######## 1722# NAME [perl #133850] another case 1723use warnings; 1724my $time = 1; 1725$_ = ""; 1726s/^/ ${time} /e 1727EXPECT 1728Ambiguous use of ${time} resolved to $time at - line 4. 1729######## 1730# NAME [perl #133850] another case 1731use warnings; 1732%x = qw(a b c d); 1733$_ = ""; 1734s/^/ @x {a} /e 1735EXPECT 1736Scalar value @x{"a"} better written as $x{"a"} at - line 4. 1737######## 1738# NAME Warn on 32-bit code points 1739# SKIP ? $Config{uvsize} < 8 1740use warnings 'portable'; 1741my $a = "\x{8000_0000}"; 1742my $b = "\o{20_000_000_000}"; 1743EXPECT 1744Code point 0x80000000 is not Unicode, requires a Perl extension, and so is not portable at - line 2. 1745Code point 0x80000000 is not Unicode, requires a Perl extension, and so is not portable at - line 3. 1746######## 1747# NAME Check that our Multidimensional array heuristic doesn't false positive on function calls 1748use warnings; 1749my $str= "rst"; 1750my $substr= "s"; 1751my @array="A".."C"; 1752# force a numeric warning, but we should NOT see a Multidimensional warning here 1753my $trigger_num_warn= $array[index $str,$substr] + 1; 1754# this should trigger a Multidimensional warning 1755my $should_warn_multi= $array[0x1,0x2]; 1756EXPECT 1757Multidimensional syntax $array[0x1,0x2] not supported at - line 8. 1758Argument "B" isn't numeric in addition (+) at - line 6. 1759######## 1760# NAME extra paired delimiters Latin1 range in UTF-8 1761BEGIN { binmode STDERR, ":utf8" } 1762use utf8; 1763use feature 'extra_paired_delimiters'; 1764no warnings 'experimental::extra_paired_delimiters'; 1765my $good = q<this string uses ASCII delimiter; no warning>; 1766my $good2 = q«this string has mirrored delimiters in either order»; 1767my $good3 = q»and reversed«; 1768no feature 'extra_paired_delimiters'; 1769my $warn3 = q«this string starts and ends with the lhs terminator«; 1770my $warn4 = q»this string starts and ends with the rhs mirror»; 1771EXPECT 1772Use of '«' is deprecated as a string delimiter at - line 9. 1773Use of '»' is deprecated as a string delimiter at - line 10. 1774######## 1775# NAME extra paired delimiters above Latin1 range 1776BEGIN { binmode STDERR, ":utf8" } 1777use utf8; 1778use feature 'extra_paired_delimiters'; 1779no warnings 'experimental::extra_paired_delimiters'; 1780my $good = q<this string uses ASCII delimiter; no warning>; 1781my $good2 = q《this string has a mirrored terminator》; 1782my $warn2 = q》this string starts and ends with the rhs mirror》; 1783my $good3 = q‹this string has mirrored delimiters in either order›; 1784my $good3 = q›and reversed‹; 1785no feature 'extra_paired_delimiters'; 1786my $warn3 = q《this string starts and ends with the lhs terminator《; 1787my $warn4 = q》this string starts and ends with the rhs mirror》; 1788my $warn5 = q‹this string starts and ends with the lhs terminator‹; 1789my $warn6 = q›this string starts and ends with the rhs mirror›; 1790EXPECT 1791Use of '》' is deprecated as a string delimiter at - line 7. 1792Use of '《' is deprecated as a string delimiter at - line 11. 1793Use of '》' is deprecated as a string delimiter at - line 12. 1794Use of '‹' is deprecated as a string delimiter at - line 13. 1795Use of '›' is deprecated as a string delimiter at - line 14. 1796######## 1797# NAME check bareword warning is a single error message 1798BEGIN { $SIG{__WARN__}= sub { print STDERR "warn: $_[0]" }; } 1799sub bar {} 1800foo bar; 1801EXPECT 1802warn: Bareword found where operator expected (Do you need to predeclare "foo"?) at - line 3, near "foo bar" 1803syntax error at - line 3, near "foo bar" 1804Execution of - aborted due to compilation errors. 1805######## 1806# NAME SIG assign heuristic warning [github #22145] 1807use warnings; 1808$SIG{INT} = uc'default'; 1809EXPECT 1810