More accurate line numbers in messages
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / toke
CommitLineData
599cee73 1toke.c AOK
2
3 we seem to have lost a few ambiguous warnings!!
4
5
599cee73 6 $a = <<;
7 Use of comma-less variable list is deprecated
8 (called 3 times via depcom)
9
10 \1 better written as $1
4438c4b7 11 use warnings 'syntax' ;
599cee73 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
599cee73 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
599cee73 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
767a6a26 80 Unrecognized escape \\%c passed through
81 $a = "\m" ;
82
83 %s number > %s non-portable
84 my $a = 0b011111111111111111111111111111110 ;
85 $a = 0b011111111111111111111111111111111 ;
86 $a = 0b111111111111111111111111111111111 ;
87 $a = 0x0fffffffe ;
88 $a = 0x0ffffffff ;
89 $a = 0x1ffffffff ;
90 $a = 0037777777776 ;
91 $a = 0037777777777 ;
92 $a = 0047777777777 ;
93
94 Integer overflow in binary number
95 my $a = 0b011111111111111111111111111111110 ;
96 $a = 0b011111111111111111111111111111111 ;
97 $a = 0b111111111111111111111111111111111 ;
98 $a = 0x0fffffffe ;
99 $a = 0x0ffffffff ;
100 $a = 0x1ffffffff ;
101 $a = 0037777777776 ;
102 $a = 0037777777777 ;
103 $a = 0047777777777 ;
599cee73 104
0453d815 105 Mandatory Warnings
106 ------------------
107 Use of "%s" without parentheses is ambiguous [check_uni]
108 rand + 4
109
110 Ambiguous use of -%s resolved as -&%s() [yylex]
111 sub fred {} ; - fred ;
112
113 Precedence problem: open %.*s should be open(%.*s) [yylex]
114 open FOO || die;
115
116 Operator or semicolon missing before %c%s [yylex]
117 Ambiguous use of %c resolved as operator %c
118 *foo *foo
119
599cee73 120__END__
121# toke.c
a4f5cc89 122use warnings 'deprecated' ;
599cee73 123format STDOUT =
124@<<< @||| @>>> @>>>
125$a $b "abc" 'def'
126.
4438c4b7 127no warnings 'deprecated' ;
0453d815 128format STDOUT =
129@<<< @||| @>>> @>>>
130$a $b "abc" 'def'
131.
599cee73 132EXPECT
133Use of comma-less variable list is deprecated at - line 5.
134Use of comma-less variable list is deprecated at - line 5.
135Use of comma-less variable list is deprecated at - line 5.
599cee73 136########
137# toke.c
4438c4b7 138use warnings 'deprecated' ;
599cee73 139$a = <<;
140
4438c4b7 141no warnings 'deprecated' ;
0453d815 142$a = <<;
143
599cee73 144EXPECT
145Use of bare << to mean <<"" is deprecated at - line 3.
146########
147# toke.c
4438c4b7 148use warnings 'syntax' ;
599cee73 149s/(abc)/\1/;
4438c4b7 150no warnings 'syntax' ;
0453d815 151s/(abc)/\1/;
599cee73 152EXPECT
153\1 better written as $1 at - line 3.
154########
155# toke.c
4438c4b7 156use warnings 'semicolon' ;
599cee73 157$a = 1
158&time ;
4438c4b7 159no warnings 'semicolon' ;
0453d815 160$a = 1
161&time ;
599cee73 162EXPECT
163Semicolon seems to be missing at - line 3.
164########
165# toke.c
4438c4b7 166use warnings 'syntax' ;
599cee73 167my $a =+ 2 ;
168$a =- 2 ;
169$a =* 2 ;
170$a =% 2 ;
171$a =& 2 ;
172$a =. 2 ;
173$a =^ 2 ;
174$a =| 2 ;
175$a =< 2 ;
176$a =/ 2 ;
177EXPECT
7f01dc7a 178Reversed += operator at - line 3.
179Reversed -= operator at - line 4.
180Reversed *= operator at - line 5.
181Reversed %= operator at - line 6.
182Reversed &= operator at - line 7.
183Reversed .= operator at - line 8.
184Reversed ^= operator at - line 9.
185Reversed |= operator at - line 10.
186Reversed <= operator at - line 11.
187syntax error at - line 8, near "=."
188syntax error at - line 9, near "=^"
189syntax error at - line 10, near "=|"
190Unterminated <> operator at - line 11.
599cee73 191########
192# toke.c
4438c4b7 193no warnings 'syntax' ;
0453d815 194my $a =+ 2 ;
195$a =- 2 ;
196$a =* 2 ;
197$a =% 2 ;
198$a =& 2 ;
199$a =. 2 ;
200$a =^ 2 ;
201$a =| 2 ;
202$a =< 2 ;
203$a =/ 2 ;
204EXPECT
7f01dc7a 205syntax error at - line 8, near "=."
206syntax error at - line 9, near "=^"
207syntax error at - line 10, near "=|"
208Unterminated <> operator at - line 11.
0453d815 209########
210# toke.c
4438c4b7 211use warnings 'syntax' ;
599cee73 212my $a = $a[1,2] ;
4438c4b7 213no warnings 'syntax' ;
0453d815 214my $a = $a[1,2] ;
599cee73 215EXPECT
216Multidimensional syntax $a[1,2] not supported at - line 3.
217########
218# toke.c
4438c4b7 219use warnings 'syntax' ;
599cee73 220sub fred {} ; $SIG{TERM} = fred;
4438c4b7 221no warnings 'syntax' ;
0453d815 222$SIG{TERM} = fred;
599cee73 223EXPECT
224You need to quote "fred" at - line 3.
225########
226# toke.c
4438c4b7 227use warnings 'syntax' ;
599cee73 228@a[3] = 2;
229@a{3} = 2;
4438c4b7 230no warnings 'syntax' ;
0453d815 231@a[3] = 2;
232@a{3} = 2;
599cee73 233EXPECT
234Scalar value @a[3] better written as $a[3] at - line 3.
235Scalar value @a{3} better written as $a{3} at - line 4.
236########
237# toke.c
4438c4b7 238use warnings 'syntax' ;
599cee73 239$_ = "ab" ;
240s/(ab)/\1/e;
4438c4b7 241no warnings 'syntax' ;
0453d815 242$_ = "ab" ;
243s/(ab)/\1/e;
599cee73 244EXPECT
245Can't use \1 to mean $1 in expression at - line 4.
246########
247# toke.c
4438c4b7 248use warnings 'reserved' ;
599cee73 249$a = abc;
1c3923b3 250$a = { def
251
252=> 1 };
4438c4b7 253no warnings 'reserved' ;
0453d815 254$a = abc;
599cee73 255EXPECT
256Unquoted string "abc" may clash with future reserved word at - line 3.
257########
258# toke.c
e476b1b5 259use warnings 'qw' ;
599cee73 260@a = qw(a, b, c) ;
e476b1b5 261no warnings 'qw' ;
0453d815 262@a = qw(a, b, c) ;
599cee73 263EXPECT
264Possible attempt to separate words with commas at - line 3.
265########
266# toke.c
e476b1b5 267use warnings 'qw' ;
599cee73 268@a = qw(a b #) ;
e476b1b5 269no warnings 'qw' ;
0453d815 270@a = qw(a b #) ;
599cee73 271EXPECT
272Possible attempt to put comments in qw() list at - line 3.
273########
274# toke.c
4438c4b7 275use warnings 'syntax' ;
599cee73 276print ("")
277EXPECT
278print (...) interpreted as function at - line 3.
279########
280# toke.c
4438c4b7 281no warnings 'syntax' ;
0453d815 282print ("")
283EXPECT
284
285########
286# toke.c
4438c4b7 287use warnings 'syntax' ;
599cee73 288printf ("")
289EXPECT
290printf (...) interpreted as function at - line 3.
291########
292# toke.c
4438c4b7 293no warnings 'syntax' ;
0453d815 294printf ("")
295EXPECT
296
297########
298# toke.c
4438c4b7 299use warnings 'syntax' ;
599cee73 300sort ("")
301EXPECT
302sort (...) interpreted as function at - line 3.
303########
304# toke.c
4438c4b7 305no warnings 'syntax' ;
0453d815 306sort ("")
307EXPECT
308
309########
310# toke.c
4438c4b7 311use warnings 'ambiguous' ;
599cee73 312$a = ${time[2]};
4438c4b7 313no warnings 'ambiguous' ;
0453d815 314$a = ${time[2]};
599cee73 315EXPECT
316Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
317########
318# toke.c
4438c4b7 319use warnings 'ambiguous' ;
599cee73 320$a = ${time{2}};
321EXPECT
322Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
323########
324# toke.c
4438c4b7 325no warnings 'ambiguous' ;
0453d815 326$a = ${time{2}};
327EXPECT
328
329########
330# toke.c
4438c4b7 331use warnings 'ambiguous' ;
599cee73 332$a = ${time} ;
4438c4b7 333no warnings 'ambiguous' ;
0453d815 334$a = ${time} ;
599cee73 335EXPECT
336Ambiguous use of ${time} resolved to $time at - line 3.
337########
338# toke.c
4438c4b7 339use warnings 'ambiguous' ;
599cee73 340sub fred {}
341$a = ${fred} ;
4438c4b7 342no warnings 'ambiguous' ;
0453d815 343$a = ${fred} ;
599cee73 344EXPECT
345Ambiguous use of ${fred} resolved to $fred at - line 4.
346########
347# toke.c
4438c4b7 348use warnings 'syntax' ;
7fd134d9 349$a = _123; print "$a\n"; #( 3 string)
350$a = 1_23; print "$a\n";
351$a = 12_3; print "$a\n";
352$a = 123_; print "$a\n"; # 6
353$a = _+123; print "$a\n"; # 7 string)
354$a = +_123; print "$a\n"; #( 8 string)
355$a = +1_23; print "$a\n";
356$a = +12_3; print "$a\n";
357$a = +123_; print "$a\n"; # 11
358$a = _-123; print "$a\n"; #(12 string)
359$a = -_123; print "$a\n"; #(13 string)
360$a = -1_23; print "$a\n";
361$a = -12_3; print "$a\n";
362$a = -123_; print "$a\n"; # 16
363$a = 123._456; print "$a\n"; # 17
364$a = 123.4_56; print "$a\n";
365$a = 123.45_6; print "$a\n";
366$a = 123.456_; print "$a\n"; # 20
367$a = +123._456; print "$a\n"; # 21
368$a = +123.4_56; print "$a\n";
369$a = +123.45_6; print "$a\n";
370$a = +123.456_; print "$a\n"; # 24
371$a = -123._456; print "$a\n"; # 25
372$a = -123.4_56; print "$a\n";
373$a = -123.45_6; print "$a\n";
374$a = -123.456_; print "$a\n"; # 28
375$a = 123.456E_12; print "$a\n"; # 29
376$a = 123.456E1_2; print "$a\n";
377$a = 123.456E12_; print "$a\n"; # 31
378$a = 123.456E_+12; print "$a\n"; # 32
379$a = 123.456E+_12; print "$a\n"; # 33
380$a = 123.456E+1_2; print "$a\n";
381$a = 123.456E+12_; print "$a\n"; # 35
382$a = 123.456E_-12; print "$a\n"; # 36
383$a = 123.456E-_12; print "$a\n"; # 37
384$a = 123.456E-1_2; print "$a\n";
385$a = 123.456E-12_; print "$a\n"; # 39
b3b48e3e 386$a = 1__23; print "$a\n"; # 40
387$a = 12.3__4; print "$a\n"; # 41
388$a = 12.34e1__2; print "$a\n"; # 42
4438c4b7 389no warnings 'syntax' ;
7fd134d9 390$a = _123; print "$a\n";
391$a = 1_23; print "$a\n";
392$a = 12_3; print "$a\n";
393$a = 123_; print "$a\n";
394$a = _+123; print "$a\n";
395$a = +_123; print "$a\n";
396$a = +1_23; print "$a\n";
397$a = +12_3; print "$a\n";
398$a = +123_; print "$a\n";
399$a = _-123; print "$a\n";
400$a = -_123; print "$a\n";
401$a = -1_23; print "$a\n";
402$a = -12_3; print "$a\n";
403$a = -123_; print "$a\n";
404$a = 123._456; print "$a\n";
405$a = 123.4_56; print "$a\n";
406$a = 123.45_6; print "$a\n";
407$a = 123.456_; print "$a\n";
408$a = +123._456; print "$a\n";
409$a = +123.4_56; print "$a\n";
410$a = +123.45_6; print "$a\n";
411$a = +123.456_; print "$a\n";
412$a = -123._456; print "$a\n";
413$a = -123.4_56; print "$a\n";
414$a = -123.45_6; print "$a\n";
415$a = -123.456_; print "$a\n";
416$a = 123.456E_12; print "$a\n";
417$a = 123.456E1_2; print "$a\n";
418$a = 123.456E12_; print "$a\n";
419$a = 123.456E_+12; print "$a\n";
420$a = 123.456E+_12; print "$a\n";
421$a = 123.456E+1_2; print "$a\n";
422$a = 123.456E+12_; print "$a\n";
423$a = 123.456E_-12; print "$a\n";
424$a = 123.456E-_12; print "$a\n";
425$a = 123.456E-1_2; print "$a\n";
426$a = 123.456E-12_; print "$a\n";
b3b48e3e 427$a = 1__23; print "$a\n";
428$a = 12.3__4; print "$a\n";
429$a = 12.34e1__2; print "$a\n";
599cee73 430EXPECT
fbfa96bd 431OPTIONS regex
928753ea 432Misplaced _ in number at - line 6.
928753ea 433Misplaced _ in number at - line 11.
7fd134d9 434Misplaced _ in number at - line 16.
928753ea 435Misplaced _ in number at - line 17.
7fd134d9 436Misplaced _ in number at - line 20.
928753ea 437Misplaced _ in number at - line 21.
7fd134d9 438Misplaced _ in number at - line 24.
439Misplaced _ in number at - line 25.
440Misplaced _ in number at - line 28.
441Misplaced _ in number at - line 29.
442Misplaced _ in number at - line 31.
443Misplaced _ in number at - line 32.
444Misplaced _ in number at - line 33.
445Misplaced _ in number at - line 35.
446Misplaced _ in number at - line 36.
447Misplaced _ in number at - line 37.
448Misplaced _ in number at - line 39.
b3b48e3e 449Misplaced _ in number at - line 40.
450Misplaced _ in number at - line 41.
451Misplaced _ in number at - line 42.
928753ea 452_123
453123
928753ea 454123
7fd134d9 455123
456123
457_123
458123
459123
460123
461-123
462-_123
463-123
464-123
465-123
466123.456
467123.456
468123.456
469123.456
470123.456
471123.456
472123.456
473123.456
474-123.456
475-123.456
476-123.456
477-123.456
478123456000000000
479123456000000000
480123456000000000
481123456000000000
482123456000000000
483123456000000000
484123456000000000
fbfa96bd 4851.23456e-0?10
4861.23456e-0?10
4871.23456e-0?10
4881.23456e-0?10
b3b48e3e 489123
49012.34
49112340000000000
7fd134d9 492_123
493123
494123
495123
496123
497_123
498123
499123
500123
501-123
502-_123
503-123
504-123
505-123
506123.456
507123.456
508123.456
509123.456
510123.456
928753ea 511123.456
512123.456
928753ea 513123.456
7fd134d9 514-123.456
515-123.456
516-123.456
517-123.456
518123456000000000
519123456000000000
520123456000000000
521123456000000000
522123456000000000
523123456000000000
524123456000000000
fbfa96bd 5251.23456e-0?10
5261.23456e-0?10
5271.23456e-0?10
5281.23456e-0?10
b3b48e3e 529123
53012.34
53112340000000000
599cee73 532########
533# toke.c
e476b1b5 534use warnings 'bareword' ;
60e6418e 535#line 25 "bar"
599cee73 536$a = FRED:: ;
e476b1b5 537no warnings 'bareword' ;
0453d815 538#line 25 "bar"
539$a = FRED:: ;
599cee73 540EXPECT
60e6418e 541Bareword "FRED::" refers to nonexistent package at bar line 25.
599cee73 542########
543# toke.c
4438c4b7 544use warnings 'ambiguous' ;
599cee73 545sub time {}
0453d815 546my $a = time() ;
4438c4b7 547no warnings 'ambiguous' ;
0453d815 548my $b = time() ;
599cee73 549EXPECT
550Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
551########
552# toke.c
26d16222 553use warnings ;
0453d815 554eval <<'EOE';
df0deb90 555# line 30 "foo"
556warn "yelp";
0453d815 557{
0453d815 558 $_ = " \x{123} " ;
559}
560EOE
561EXPECT
df0deb90 562yelp at foo line 30.
0453d815 563########
564# toke.c
0453d815 565my $a = rand + 4 ;
566EXPECT
567Warning: Use of "rand" without parens is ambiguous at - line 2.
568########
569# toke.c
570$^W = 0 ;
571my $a = rand + 4 ;
572{
4438c4b7 573 no warnings 'ambiguous' ;
0453d815 574 $a = rand + 4 ;
4438c4b7 575 use warnings 'ambiguous' ;
0453d815 576 $a = rand + 4 ;
577}
578$a = rand + 4 ;
579EXPECT
580Warning: Use of "rand" without parens is ambiguous at - line 3.
581Warning: Use of "rand" without parens is ambiguous at - line 8.
582Warning: Use of "rand" without parens is ambiguous at - line 10.
583########
584# toke.c
585sub fred {};
586-fred ;
587EXPECT
588Ambiguous use of -fred resolved as -&fred() at - line 3.
589########
590# toke.c
591$^W = 0 ;
592sub fred {} ;
593-fred ;
594{
4438c4b7 595 no warnings 'ambiguous' ;
0453d815 596 -fred ;
4438c4b7 597 use warnings 'ambiguous' ;
0453d815 598 -fred ;
599}
600-fred ;
601EXPECT
602Ambiguous use of -fred resolved as -&fred() at - line 4.
603Ambiguous use of -fred resolved as -&fred() at - line 9.
604Ambiguous use of -fred resolved as -&fred() at - line 11.
605########
606# toke.c
607open FOO || time;
608EXPECT
609Precedence problem: open FOO should be open(FOO) at - line 2.
610########
611# toke.c
612$^W = 0 ;
613open FOO || time;
614{
e476b1b5 615 no warnings 'precedence' ;
0453d815 616 open FOO || time;
e476b1b5 617 use warnings 'precedence' ;
0453d815 618 open FOO || time;
619}
620open FOO || time;
621EXPECT
622Precedence problem: open FOO should be open(FOO) at - line 3.
623Precedence problem: open FOO should be open(FOO) at - line 8.
624Precedence problem: open FOO should be open(FOO) at - line 10.
625########
626# toke.c
627$^W = 0 ;
628*foo *foo ;
629{
4438c4b7 630 no warnings 'ambiguous' ;
0453d815 631 *foo *foo ;
4438c4b7 632 use warnings 'ambiguous' ;
0453d815 633 *foo *foo ;
634}
635*foo *foo ;
636EXPECT
637Operator or semicolon missing before *foo at - line 3.
638Ambiguous use of * resolved as operator * at - line 3.
639Operator or semicolon missing before *foo at - line 8.
640Ambiguous use of * resolved as operator * at - line 8.
641Operator or semicolon missing before *foo at - line 10.
642Ambiguous use of * resolved as operator * at - line 10.
767a6a26 643########
644# toke.c
e476b1b5 645use warnings 'misc' ;
767a6a26 646my $a = "\m" ;
e476b1b5 647no warnings 'misc' ;
767a6a26 648$a = "\m" ;
649EXPECT
650Unrecognized escape \m passed through at - line 3.
651########
652# toke.c
653use warnings 'portable' ;
654my $a = 0b011111111111111111111111111111110 ;
655 $a = 0b011111111111111111111111111111111 ;
656 $a = 0b111111111111111111111111111111111 ;
657 $a = 0x0fffffffe ;
658 $a = 0x0ffffffff ;
659 $a = 0x1ffffffff ;
660 $a = 0037777777776 ;
661 $a = 0037777777777 ;
662 $a = 0047777777777 ;
663no warnings 'portable' ;
664 $a = 0b011111111111111111111111111111110 ;
665 $a = 0b011111111111111111111111111111111 ;
666 $a = 0b111111111111111111111111111111111 ;
667 $a = 0x0fffffffe ;
668 $a = 0x0ffffffff ;
669 $a = 0x1ffffffff ;
670 $a = 0037777777776 ;
671 $a = 0037777777777 ;
672 $a = 0047777777777 ;
673EXPECT
674Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
675Hexadecimal number > 0xffffffff non-portable at - line 8.
676Octal number > 037777777777 non-portable at - line 11.
677########
678# toke.c
679use warnings 'overflow' ;
680my $a = 0b011111111111111111111111111111110 ;
681 $a = 0b011111111111111111111111111111111 ;
15041a67 682 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26 683 $a = 0x0fffffffe ;
684 $a = 0x0ffffffff ;
15041a67 685 $a = 0x10000000000000000 ;
767a6a26 686 $a = 0037777777776 ;
687 $a = 0037777777777 ;
15041a67 688 $a = 002000000000000000000000;
767a6a26 689no warnings 'overflow' ;
690 $a = 0b011111111111111111111111111111110 ;
691 $a = 0b011111111111111111111111111111111 ;
15041a67 692 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26 693 $a = 0x0fffffffe ;
694 $a = 0x0ffffffff ;
15041a67 695 $a = 0x10000000000000000 ;
767a6a26 696 $a = 0037777777776 ;
697 $a = 0037777777777 ;
15041a67 698 $a = 002000000000000000000000;
767a6a26 699EXPECT
700Integer overflow in binary number at - line 5.
701Integer overflow in hexadecimal number at - line 8.
702Integer overflow in octal number at - line 11.
8593bda5 703########
704# toke.c
705use warnings 'ambiguous';
706"@mjd_previously_unused_array";
707no warnings 'ambiguous';
708"@mjd_previously_unused_array";
709EXPECT
710Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.