This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: "CORE::%s is not a keyword" cleanup.
[perl5.git] / t / lib / warnings / toke
CommitLineData
599cee73
PM
1toke.c AOK
2
3 we seem to have lost a few ambiguous warnings!!
4
5
599cee73
PM
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
PM
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
PM
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
PM
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
PM
80 Unrecognized escape \\%c passed through
81 $a = "\m" ;
82
820438b1 83 Useless use of \\E.
52ed07f6
BF
84 $a = "abcd\E" ;
85
767a6a26
PM
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 ;
ac206dc8
RGS
107
108 dump() better written as CORE::dump()
4ac733c9
MJD
109
110 Use of /c modifier is meaningless without /g
111
64e578a2
MJD
112 Use of /c modifier is meaningless in s///
113
0453d815
PM
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
599cee73
PM
129__END__
130# toke.c
599cee73
PM
131format STDOUT =
132@<<< @||| @>>> @>>>
133$a $b "abc" 'def'
134.
4438c4b7 135no warnings 'deprecated' ;
0453d815
PM
136format STDOUT =
137@<<< @||| @>>> @>>>
138$a $b "abc" 'def'
139.
599cee73 140EXPECT
d1d15184
NC
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.
599cee73
PM
144########
145# toke.c
e6897b1a 146$a =~ m/$foo/sand $bar;
aa78b661 147$a =~ s/$foo/fool/sand $bar;
599cee73
PM
148$a = <<;
149
4438c4b7 150no warnings 'deprecated' ;
e6897b1a 151$a =~ m/$foo/sand $bar;
aa78b661 152$a =~ s/$foo/fool/sand $bar;
0453d815
PM
153$a = <<;
154
599cee73 155EXPECT
e6897b1a 156Having no space between pattern and following word is deprecated at - line 2.
aa78b661
KW
157Having no space between pattern and following word is deprecated at - line 3.
158Use of bare << to mean <<"" is deprecated at - line 4.
599cee73
PM
159########
160# toke.c
4438c4b7 161use warnings 'syntax' ;
599cee73 162s/(abc)/\1/;
4438c4b7 163no warnings 'syntax' ;
0453d815 164s/(abc)/\1/;
599cee73
PM
165EXPECT
166\1 better written as $1 at - line 3.
167########
168# toke.c
4438c4b7 169use warnings 'semicolon' ;
599cee73
PM
170$a = 1
171&time ;
4438c4b7 172no warnings 'semicolon' ;
0453d815
PM
173$a = 1
174&time ;
599cee73
PM
175EXPECT
176Semicolon seems to be missing at - line 3.
177########
178# toke.c
4438c4b7 179use warnings 'syntax' ;
599cee73
PM
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
7f01dc7a
JH
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.
599cee73
PM
204########
205# toke.c
4438c4b7 206no warnings 'syntax' ;
0453d815
PM
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
7f01dc7a
JH
218syntax error at - line 8, near "=."
219syntax error at - line 9, near "=^"
220syntax error at - line 10, near "=|"
221Unterminated <> operator at - line 11.
0453d815
PM
222########
223# toke.c
4438c4b7 224use warnings 'syntax' ;
599cee73 225my $a = $a[1,2] ;
4438c4b7 226no warnings 'syntax' ;
0453d815 227my $a = $a[1,2] ;
599cee73
PM
228EXPECT
229Multidimensional syntax $a[1,2] not supported at - line 3.
230########
231# toke.c
4438c4b7 232use warnings 'syntax' ;
599cee73 233sub fred {} ; $SIG{TERM} = fred;
4438c4b7 234no warnings 'syntax' ;
0453d815 235$SIG{TERM} = fred;
599cee73
PM
236EXPECT
237You need to quote "fred" at - line 3.
238########
239# toke.c
4c01a014
BF
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
4438c4b7 260use warnings 'syntax' ;
599cee73
PM
261@a[3] = 2;
262@a{3} = 2;
4438c4b7 263no warnings 'syntax' ;
0453d815
PM
264@a[3] = 2;
265@a{3} = 2;
599cee73
PM
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
b9e186cd
BF
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
4438c4b7 297use warnings 'syntax' ;
599cee73
PM
298$_ = "ab" ;
299s/(ab)/\1/e;
4438c4b7 300no warnings 'syntax' ;
0453d815
PM
301$_ = "ab" ;
302s/(ab)/\1/e;
599cee73
PM
303EXPECT
304Can't use \1 to mean $1 in expression at - line 4.
305########
306# toke.c
4438c4b7 307use warnings 'reserved' ;
599cee73 308$a = abc;
1c3923b3
GS
309$a = { def
310
311=> 1 };
4438c4b7 312no warnings 'reserved' ;
0453d815 313$a = abc;
599cee73
PM
314EXPECT
315Unquoted string "abc" may clash with future reserved word at - line 3.
316########
317# toke.c
e476b1b5 318use warnings 'qw' ;
599cee73 319@a = qw(a, b, c) ;
e476b1b5 320no warnings 'qw' ;
0453d815 321@a = qw(a, b, c) ;
599cee73
PM
322EXPECT
323Possible attempt to separate words with commas at - line 3.
324########
325# toke.c
e476b1b5 326use warnings 'qw' ;
7e03b518 327@a = qw(a b c # #) ;
e476b1b5 328no warnings 'qw' ;
7e03b518 329@a = qw(a b c # #) ;
599cee73
PM
330EXPECT
331Possible attempt to put comments in qw() list at - line 3.
332########
333# toke.c
7e03b518
EB
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
4438c4b7 343use warnings 'syntax' ;
b1439985
RGS
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;
599cee73 350EXPECT
b1439985 351print (...) interpreted as function at - line 7.
599cee73
PM
352########
353# toke.c
4438c4b7 354no warnings 'syntax' ;
0453d815
PM
355print ("")
356EXPECT
357
358########
359# toke.c
4438c4b7 360use warnings 'syntax' ;
b1439985
RGS
361printf ("");
362printf ("") . '';
599cee73 363EXPECT
b1439985 364printf (...) interpreted as function at - line 4.
599cee73
PM
365########
366# toke.c
4438c4b7 367no warnings 'syntax' ;
0453d815
PM
368printf ("")
369EXPECT
370
371########
372# toke.c
4438c4b7 373use warnings 'syntax' ;
b1439985
RGS
374sort ("");
375sort ("") . '';
599cee73 376EXPECT
b1439985 377sort (...) interpreted as function at - line 4.
599cee73
PM
378########
379# toke.c
4438c4b7 380no warnings 'syntax' ;
0453d815
PM
381sort ("")
382EXPECT
383
384########
385# toke.c
4438c4b7 386use warnings 'ambiguous' ;
599cee73 387$a = ${time[2]};
4438c4b7 388no warnings 'ambiguous' ;
0453d815 389$a = ${time[2]};
599cee73
PM
390EXPECT
391Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
392########
393# toke.c
4438c4b7 394use warnings 'ambiguous' ;
599cee73
PM
395$a = ${time{2}};
396EXPECT
397Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
398########
399# toke.c
4438c4b7 400no warnings 'ambiguous' ;
0453d815
PM
401$a = ${time{2}};
402EXPECT
403
404########
405# toke.c
4438c4b7 406use warnings 'ambiguous' ;
599cee73 407$a = ${time} ;
4438c4b7 408no warnings 'ambiguous' ;
0453d815 409$a = ${time} ;
599cee73
PM
410EXPECT
411Ambiguous use of ${time} resolved to $time at - line 3.
412########
413# toke.c
4438c4b7 414use warnings 'ambiguous' ;
599cee73
PM
415sub fred {}
416$a = ${fred} ;
4438c4b7 417no warnings 'ambiguous' ;
0453d815 418$a = ${fred} ;
599cee73
PM
419EXPECT
420Ambiguous use of ${fred} resolved to $fred at - line 4.
421########
422# toke.c
4438c4b7 423use warnings 'syntax' ;
7fd134d9
JH
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
2bea9a37
JH
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
7fd134d9
JH
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
b3b48e3e
JH
461$a = 1__23; print "$a\n"; # 40
462$a = 12.3__4; print "$a\n"; # 41
2bea9a37 463$a = 12.34e1__2; printf("%.0f\n", $a); # 42
4438c4b7 464no warnings 'syntax' ;
7fd134d9
JH
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";
2bea9a37
JH
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);
7fd134d9
JH
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";
b3b48e3e
JH
502$a = 1__23; print "$a\n";
503$a = 12.3__4; print "$a\n";
2bea9a37 504$a = 12.34e1__2; printf("%.0f\n", $a);
599cee73 505EXPECT
fbfa96bd 506OPTIONS regex
928753ea 507Misplaced _ in number at - line 6.
928753ea 508Misplaced _ in number at - line 11.
7fd134d9 509Misplaced _ in number at - line 16.
928753ea 510Misplaced _ in number at - line 17.
7fd134d9 511Misplaced _ in number at - line 20.
928753ea 512Misplaced _ in number at - line 21.
7fd134d9
JH
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.
b3b48e3e
JH
524Misplaced _ in number at - line 40.
525Misplaced _ in number at - line 41.
526Misplaced _ in number at - line 42.
928753ea
JH
527_123
528123
928753ea 529123
7fd134d9
JH
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
fbfa96bd
NIS
5601.23456e-0?10
5611.23456e-0?10
5621.23456e-0?10
5631.23456e-0?10
b3b48e3e
JH
564123
56512.34
56612340000000000
7fd134d9
JH
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
928753ea
JH
586123.456
587123.456
928753ea 588123.456
7fd134d9
JH
589-123.456
590-123.456
591-123.456
592-123.456
593123456000000000
594123456000000000
595123456000000000
596123456000000000
597123456000000000
598123456000000000
599123456000000000
fbfa96bd
NIS
6001.23456e-0?10
6011.23456e-0?10
6021.23456e-0?10
6031.23456e-0?10
b3b48e3e
JH
604123
60512.34
60612340000000000
599cee73
PM
607########
608# toke.c
e476b1b5 609use warnings 'bareword' ;
60e6418e 610#line 25 "bar"
599cee73 611$a = FRED:: ;
e476b1b5 612no warnings 'bareword' ;
0453d815
PM
613#line 25 "bar"
614$a = FRED:: ;
599cee73 615EXPECT
60e6418e 616Bareword "FRED::" refers to nonexistent package at bar line 25.
979a1401
BF
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.
599cee73
PM
641########
642# toke.c
4438c4b7 643use warnings 'ambiguous' ;
599cee73 644sub time {}
0453d815 645my $a = time() ;
4438c4b7 646no warnings 'ambiguous' ;
0453d815 647my $b = time() ;
599cee73
PM
648EXPECT
649Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
650########
651# toke.c
26d16222 652use warnings ;
0453d815 653eval <<'EOE';
df0deb90
GS
654# line 30 "foo"
655warn "yelp";
0453d815 656{
0453d815
PM
657 $_ = " \x{123} " ;
658}
659EOE
660EXPECT
df0deb90 661yelp at foo line 30.
0453d815
PM
662########
663# toke.c
0453d815
PM
664my $a = rand + 4 ;
665EXPECT
2d5ccbba 666Warning: Use of "rand" without parentheses is ambiguous at - line 2.
0453d815
PM
667########
668# toke.c
669$^W = 0 ;
670my $a = rand + 4 ;
671{
4438c4b7 672 no warnings 'ambiguous' ;
0453d815 673 $a = rand + 4 ;
4438c4b7 674 use warnings 'ambiguous' ;
0453d815
PM
675 $a = rand + 4 ;
676}
677$a = rand + 4 ;
678EXPECT
2d5ccbba
IT
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.
0453d815 682########
e19a021b
FC
683# [perl #97110]
684sub myrand(;$) { }
b5fb7ce3 685sub whatever($) { }
e19a021b 686my $a = myrand + 4 ;
b5fb7ce3 687my $b = whatever + 4 ;
e19a021b 688EXPECT
b5fb7ce3 689Warning: Use of "myrand" without parentheses is ambiguous at - line 4.
e19a021b 690########
0453d815 691# toke.c
e8ae98db
RGS
692use warnings "ambiguous";
693print for keys %+; # should not warn
694EXPECT
695########
696# toke.c
0453d815
PM
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{
4438c4b7 707 no warnings 'ambiguous' ;
0453d815 708 -fred ;
4438c4b7 709 use warnings 'ambiguous' ;
0453d815
PM
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
43b5ab4c
BF
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
0453d815 771open FOO || time;
240d1b6f 772open local *FOO; # should be ok
0453d815
PM
773EXPECT
774Precedence problem: open FOO should be open(FOO) at - line 2.
775########
66fbe8fb
HS
776# toke.c (and [perl #16184])
777open FOO => "<&0"; close FOO;
778EXPECT
779########
0453d815
PM
780# toke.c
781$^W = 0 ;
782open FOO || time;
783{
e476b1b5 784 no warnings 'precedence' ;
0453d815 785 open FOO || time;
e476b1b5 786 use warnings 'precedence' ;
0453d815
PM
787 open FOO || time;
788}
789open FOO || time;
db3abe52 790open Foo::BAR; # this should not warn
0453d815
PM
791EXPECT
792Precedence problem: open FOO should be open(FOO) at - line 3.
793Precedence problem: open FOO should be open(FOO) at - line 8.
794Precedence problem: open FOO should be open(FOO) at - line 10.
795########
796# toke.c
797$^W = 0 ;
798*foo *foo ;
799{
4438c4b7 800 no warnings 'ambiguous' ;
0453d815 801 *foo *foo ;
4438c4b7 802 use warnings 'ambiguous' ;
0453d815
PM
803 *foo *foo ;
804}
805*foo *foo ;
806EXPECT
807Operator or semicolon missing before *foo at - line 3.
808Ambiguous use of * resolved as operator * at - line 3.
809Operator or semicolon missing before *foo at - line 8.
810Ambiguous use of * resolved as operator * at - line 8.
811Operator or semicolon missing before *foo at - line 10.
812Ambiguous use of * resolved as operator * at - line 10.
767a6a26
PM
813########
814# toke.c
02571fe8
BF
815use utf8;
816use open qw( :utf8 :std );
817$^W = 0 ;
818*foo *foo ;
819{
820 no warnings 'ambiguous' ;
821 *foo *foo ;
822 use warnings 'ambiguous' ;
823 *foo *foo ;
824}
825*foo *foo ;
826EXPECT
827Operator or semicolon missing before *foo at - line 5.
828Ambiguous use of * resolved as operator * at - line 5.
829Operator or semicolon missing before *foo at - line 10.
830Ambiguous use of * resolved as operator * at - line 10.
831Operator or semicolon missing before *foo at - line 12.
832Ambiguous use of * resolved as operator * at - line 12.
833########
834# toke.c
e476b1b5 835use warnings 'misc' ;
767a6a26 836my $a = "\m" ;
e476b1b5 837no warnings 'misc' ;
767a6a26
PM
838$a = "\m" ;
839EXPECT
840Unrecognized escape \m passed through at - line 3.
841########
842# toke.c
52ed07f6
BF
843use warnings 'misc' ;
844my $a = "abcd\E" ;
845no warnings 'misc' ;
846$a = "abcd\E" ;
847EXPECT
820438b1 848Useless use of \E at - line 3.
52ed07f6
BF
849########
850# toke.c
767a6a26
PM
851use warnings 'portable' ;
852my $a = 0b011111111111111111111111111111110 ;
853 $a = 0b011111111111111111111111111111111 ;
854 $a = 0b111111111111111111111111111111111 ;
855 $a = 0x0fffffffe ;
856 $a = 0x0ffffffff ;
857 $a = 0x1ffffffff ;
858 $a = 0037777777776 ;
859 $a = 0037777777777 ;
860 $a = 0047777777777 ;
861no warnings 'portable' ;
862 $a = 0b011111111111111111111111111111110 ;
863 $a = 0b011111111111111111111111111111111 ;
864 $a = 0b111111111111111111111111111111111 ;
865 $a = 0x0fffffffe ;
866 $a = 0x0ffffffff ;
867 $a = 0x1ffffffff ;
868 $a = 0037777777776 ;
869 $a = 0037777777777 ;
870 $a = 0047777777777 ;
871EXPECT
872Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
873Hexadecimal number > 0xffffffff non-portable at - line 8.
874Octal number > 037777777777 non-portable at - line 11.
875########
876# toke.c
877use warnings 'overflow' ;
878my $a = 0b011111111111111111111111111111110 ;
879 $a = 0b011111111111111111111111111111111 ;
15041a67 880 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
881 $a = 0x0fffffffe ;
882 $a = 0x0ffffffff ;
15041a67 883 $a = 0x10000000000000000 ;
767a6a26
PM
884 $a = 0037777777776 ;
885 $a = 0037777777777 ;
15041a67 886 $a = 002000000000000000000000;
767a6a26
PM
887no warnings 'overflow' ;
888 $a = 0b011111111111111111111111111111110 ;
889 $a = 0b011111111111111111111111111111111 ;
15041a67 890 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
891 $a = 0x0fffffffe ;
892 $a = 0x0ffffffff ;
15041a67 893 $a = 0x10000000000000000 ;
767a6a26
PM
894 $a = 0037777777776 ;
895 $a = 0037777777777 ;
15041a67 896 $a = 002000000000000000000000;
767a6a26
PM
897EXPECT
898Integer overflow in binary number at - line 5.
899Integer overflow in hexadecimal number at - line 8.
900Integer overflow in octal number at - line 11.
8593bda5
GS
901########
902# toke.c
ac206dc8
RGS
903BEGIN { $^C = 1; }
904use warnings 'misc';
905dump;
906CORE::dump;
907EXPECT
908dump() better written as CORE::dump() at - line 4.
909- syntax OK
910########
911# toke.c
912use warnings 'misc';
913use subs qw/dump/;
93f09d7b 914sub dump { print "no warning for overridden dump\n"; }
ac206dc8
RGS
915dump;
916EXPECT
93f09d7b 917no warning for overridden dump
ac206dc8
RGS
918########
919# toke.c
8593bda5
GS
920use warnings 'ambiguous';
921"@mjd_previously_unused_array";
922no warnings 'ambiguous';
29fb1d0e 923"@mjd_previously_unused_array2";
8593bda5
GS
924EXPECT
925Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.
707afd92
MS
926########
927# toke.c
29fb1d0e
BF
928use utf8;
929use open qw( :utf8 :std );
930use warnings 'ambiguous';
931"@mjd_previously_unused_àrray";
932no warnings 'ambiguous';
933"@mjd_previously_unused_àrray2";
934EXPECT
935Possible unintended interpolation of @mjd_previously_unused_àrray in string at - line 5.
936########
937# toke.c
938use utf8;
939use open qw( :utf8 :std );
940use warnings 'ambiguous';
941"@mjd_previously_unused_ぁrrぁy";
942no warnings 'ambiguous';
943"@mjd_previously_unused_ぁrrぁy2";
944EXPECT
945Possible unintended interpolation of @mjd_previously_unused_ぁrrぁy in string at - line 5.
946########
947# toke.c
d8c55666 948# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
949use warnings 'regexp';
950"foo" =~ /foo/c;
64e578a2 951"foo" =~ /foo/cg;
4ac733c9
MJD
952no warnings 'regexp';
953"foo" =~ /foo/c;
64e578a2 954"foo" =~ /foo/cg;
4ac733c9
MJD
955EXPECT
956Use of /c modifier is meaningless without /g at - line 4.
957########
958# toke.c
d8c55666 959# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
960use warnings 'regexp';
961$_ = "ab" ;
962s/ab/ab/c;
64e578a2 963s/ab/ab/cg;
4ac733c9
MJD
964no warnings 'regexp';
965s/ab/ab/c;
64e578a2 966s/ab/ab/cg;
4ac733c9 967EXPECT
64e578a2
MJD
968Use of /c modifier is meaningless in s/// at - line 5.
969Use of /c modifier is meaningless in s/// at - line 6.
d8c55666
MJD
970########
971-wa
972# toke.c
973# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
974print "@F\n";
975EXPECT
976
977########
978-w
979# toke.c
980# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
981print "@F\n";
982EXPECT
983Possible unintended interpolation of @F in string at - line 4.
984Name "main::F" used only once: possible typo at - line 4.
985########
986-wa
987# toke.c
988# 20020414 mjd-perl-patch+@plover.com
989EXPECT
990
2710853f
MJD
991########
992# toke.c
993# 20020414 mjd-perl-patch+@plover.com
994# In 5.7.3, this emitted "Possible unintended interpolation" warnings
995use warnings 'ambiguous';
996$s = "(@-)(@+)";
997EXPECT
998
56da5a46
RGS
999########
1000# toke.c
1001# mandatory warning
1002eval q/if ($a) { } elseif ($b) { }/;
1003no warnings "syntax";
1004eval q/if ($a) { } elseif ($b) { }/;
1005EXPECT
1006elseif should be elsif at (eval 1) line 1.
1007########
1008# toke.c
1009# mandatory warning
1010eval q/5 6/;
1011no warnings "syntax";
1012eval q/5 6/;
1013EXPECT
1014Number found where operator expected at (eval 1) line 1, near "5 6"
1015 (Missing operator before 6?)
984200d0
YST
1016########
1017# toke.c
1018use warnings "syntax";
1019$_ = $a = 1;
1020$a !=~ /1/;
1021$a !=~ m#1#;
1022$a !=~/1/;
1023$a !=~ ?/?;
decca21c
YST
1024$a !=~ y/1//;
1025$a !=~ tr/1//;
1026$a !=~ s/1//;
984200d0
YST
1027$a != ~/1/;
1028no warnings "syntax";
1029$a !=~ /1/;
1030$a !=~ m#1#;
1031$a !=~/1/;
1032$a !=~ ?/?;
decca21c
YST
1033$a !=~ y/1//;
1034$a !=~ tr/1//;
1035$a !=~ s/1//;
984200d0
YST
1036EXPECT
1037!=~ should be !~ at - line 4.
1038!=~ should be !~ at - line 5.
1039!=~ should be !~ at - line 6.
1040!=~ should be !~ at - line 7.
decca21c
YST
1041!=~ should be !~ at - line 8.
1042!=~ should be !~ at - line 9.
1043!=~ should be !~ at - line 10.
1108974d
RGS
1044########
1045# toke.c
1046our $foo :unique;
8e5dadda
NC
1047sub pam :locked;
1048sub glipp :locked {
1049}
1050sub whack_eth ($) : locked {
1051}
d1d15184 1052no warnings 'deprecated';
1108974d 1053our $bar :unique;
8e5dadda
NC
1054sub zapeth :locked;
1055sub ker_plop :locked {
1056}
1057sub swa_a_p ($) : locked {
1058}
1108974d 1059EXPECT
d1d15184
NC
1060Use of :unique is deprecated at - line 2.
1061Use of :locked is deprecated at - line 3.
1062Use of :locked is deprecated at - line 4.
1063Use of :locked is deprecated at - line 6.
9e8d7757
RB
1064########
1065# toke.c
1066use warnings "syntax";
1067sub proto_after_array(@$);
1068sub proto_after_arref(\@$);
1069sub proto_after_arref2(\[@$]);
1070sub proto_after_arref3(\[@$]_);
1071sub proto_after_hash(%$);
1072sub proto_after_hashref(\%$);
1073sub proto_after_hashref2(\[%$]);
1074sub underscore_last_pos($_);
1075sub underscore2($_;$);
1076sub underscore_fail($_$);
1077sub underscore_after_at(@_);
1078no warnings "syntax";
1079sub proto_after_array(@$);
1080sub proto_after_hash(%$);
1081sub underscore_fail($_$);
1082EXPECT
1083Prototype after '@' for main::proto_after_array : @$ at - line 3.
1084Prototype after '%' for main::proto_after_hash : %$ at - line 7.
aef2a98a 1085Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12.
9e8d7757 1086Prototype after '@' for main::underscore_after_at : @_ at - line 13.
77772344
B
1087########
1088# toke.c
1089use warnings "ambiguous";
1090"foo\nn" =~ /^foo$\n/;
1091"foo\nn" =~ /^foo${\}n/;
1092my $foo = qr/^foo$\n/;
1093my $bar = qr/^foo${\}n/;
1094no warnings "ambiguous";
1095"foo\nn" =~ /^foo$\n/;
1096"foo\nn" =~ /^foo${\}n/;
1097my $foo = qr/^foo$\n/;
1098my $bar = qr/^foo${\}n/;
1099EXPECT
1100Possible unintended interpolation of $\ in regex at - line 3.
1101Possible unintended interpolation of $\ in regex at - line 5.
d83f38d8
NC
1102########
1103# toke.c
f0a2b745
KW
1104use warnings 'syntax' ;
1105my $a = "\o";
1106my $a = "\o{";
1107my $a = "\o{}";
1108no warnings 'syntax' ;
1109my $a = "\o";
1110my $a = "\o{";
1111my $a = "\o{}";
1112EXPECT
1113Missing braces on \o{} at - line 3, within string
1114Missing right brace on \o{ at - line 4, within string
1115Number with no digits at - line 5, within string
1116BEGIN not safe after errors--compilation aborted at - line 6.
1117########
1118# toke.c
1119use warnings 'digit' ;
1120my $a = "\o{1238456}";
1121no warnings 'digit' ;
1122my $a = "\o{1238456}";
1123EXPECT
1124Non-octal character '8'. Resolved as "\o{123}" at - line 3.
725a61d7
Z
1125########
1126# toke.c
1127use warnings;
1128my $a = "foo";
1129print $a =~ ?f? ? "yes\n" : "no\n" foreach 0..2;
1130EXPECT
1131Use of ?PATTERN? without explicit operator is deprecated at - line 4.
1132yes
1133no
1134no
17a3df4c
KW
1135########
1136# toke.c
1137use warnings;
1138my $a = "\c{ack}";
1139$a = "\c,";
1140$a = "\c`";
1141no warnings 'syntax';
1142$a = "\c{ack}";
1143$a = "\c,";
1144$a = "\c`";
1145no warnings 'deprecated';
1146EXPECT
1147"\c{" is deprecated and is more clearly written as ";" at - line 3.
1148"\c," is more clearly written simply as "l" at - line 4.
1149"\c`" is more clearly written simply as "\ " at - line 5.
1150"\c{" is deprecated and is more clearly written as ";" at - line 7.
3955e1a9
KW
1151########
1152# toke.c
1153use warnings 'syntax' ;
1154my $a = qr/foo/du;
ff3f26d2 1155$a = qr/foo/lai;
3955e1a9 1156$a = qr/foo/lil;
ff3f26d2
KW
1157$a = qr/foo/aia;
1158$a = qr/foo/aaia;
3955e1a9
KW
1159no warnings 'syntax' ;
1160my $a = qr/foo/du;
1161EXPECT
1162Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= "
1163Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= "
1164Regexp modifier "/l" may not appear twice at - line 5, near "= "
ff3f26d2
KW
1165Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= "
1166BEGIN not safe after errors--compilation aborted at - line 8.
ba05d9aa
FC
1167########
1168# toke.c
1169# [perl #4362]
1170eval "print q\xabfoo";
1171print "ok\n" if
1172 $@ =~ /Can't find string terminator "\xab" anywhere before EOF/;
1173EXPECT
1174ok
5c66c3dd
BF
1175########
1176# toke.c
1177use utf8;
1178use open qw( :utf8 :std );
1179use warnings 'ambiguous' ;
1180sub frèd {}
1181$a = ${frèd} ;
1182no warnings 'ambiguous' ;
1183$a = ${frèd} ;
1184EXPECT
1185Ambiguous use of ${frèd} resolved to $frèd at - line 6.
1186########
1187# toke.c
1188use utf8;
1189use open qw( :utf8 :std );
1190use warnings 'ambiguous' ;
1191sub f렏 {}
1192$a = ${f렏} ;
1193no warnings 'ambiguous' ;
1194$a = ${f렏} ;
1195EXPECT
1196Ambiguous use of ${f렏} resolved to $f렏 at - line 6.
3773592b
BF
1197########
1198# toke.c
1199use utf8;
1200use open qw( :utf8 :std );
1201use warnings;
1202CORE::렏;
1203EXPECT
1204CORE::렏 is not a keyword at - line 5.