This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Require space between regex and following alnum operator
[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
599cee73
PM
146$a = <<;
147
4438c4b7 148no warnings 'deprecated' ;
0453d815
PM
149$a = <<;
150
599cee73 151EXPECT
0da72d5e
KW
152Use of bare << to mean <<"" is deprecated at - line 2.
153########
154# toke.c
155$a =~ m/$foo/eq;
156$a =~ s/$foo/fool/seq;
157
158EXPECT
159OPTION fatal
160Unknown regexp modifier "/e" at - line 2, near "=~ "
161Unknown regexp modifier "/q" at - line 2, near "=~ "
162Unknown regexp modifier "/q" at - line 3, near "=~ "
163Execution of - aborted due to compilation errors.
599cee73
PM
164########
165# toke.c
4438c4b7 166use warnings 'syntax' ;
599cee73 167s/(abc)/\1/;
4438c4b7 168no warnings 'syntax' ;
0453d815 169s/(abc)/\1/;
599cee73
PM
170EXPECT
171\1 better written as $1 at - line 3.
172########
173# toke.c
4438c4b7 174use warnings 'semicolon' ;
599cee73
PM
175$a = 1
176&time ;
4438c4b7 177no warnings 'semicolon' ;
0453d815
PM
178$a = 1
179&time ;
599cee73
PM
180EXPECT
181Semicolon seems to be missing at - line 3.
182########
183# toke.c
4438c4b7 184use warnings 'syntax' ;
599cee73
PM
185my $a =+ 2 ;
186$a =- 2 ;
187$a =* 2 ;
188$a =% 2 ;
189$a =& 2 ;
190$a =. 2 ;
191$a =^ 2 ;
192$a =| 2 ;
193$a =< 2 ;
194$a =/ 2 ;
195EXPECT
7f01dc7a
JH
196Reversed += operator at - line 3.
197Reversed -= operator at - line 4.
198Reversed *= operator at - line 5.
199Reversed %= operator at - line 6.
200Reversed &= operator at - line 7.
201Reversed .= operator at - line 8.
202Reversed ^= operator at - line 9.
203Reversed |= operator at - line 10.
204Reversed <= operator at - line 11.
205syntax error at - line 8, near "=."
206syntax error at - line 9, near "=^"
207syntax error at - line 10, near "=|"
208Unterminated <> operator at - line 11.
599cee73
PM
209########
210# toke.c
4438c4b7 211no warnings 'syntax' ;
0453d815
PM
212my $a =+ 2 ;
213$a =- 2 ;
214$a =* 2 ;
215$a =% 2 ;
216$a =& 2 ;
217$a =. 2 ;
218$a =^ 2 ;
219$a =| 2 ;
220$a =< 2 ;
221$a =/ 2 ;
222EXPECT
7f01dc7a
JH
223syntax error at - line 8, near "=."
224syntax error at - line 9, near "=^"
225syntax error at - line 10, near "=|"
226Unterminated <> operator at - line 11.
0453d815
PM
227########
228# toke.c
4438c4b7 229use warnings 'syntax' ;
599cee73 230my $a = $a[1,2] ;
4438c4b7 231no warnings 'syntax' ;
0453d815 232my $a = $a[1,2] ;
599cee73
PM
233EXPECT
234Multidimensional syntax $a[1,2] not supported at - line 3.
235########
236# toke.c
4438c4b7 237use warnings 'syntax' ;
599cee73 238sub fred {} ; $SIG{TERM} = fred;
4438c4b7 239no warnings 'syntax' ;
0453d815 240$SIG{TERM} = fred;
599cee73
PM
241EXPECT
242You need to quote "fred" at - line 3.
243########
244# toke.c
4c01a014
BF
245use utf8;
246use open qw( :utf8 :std );
247use warnings 'syntax' ;
248sub frèd {} ; $SIG{TERM} = frèd;
249no warnings 'syntax' ;
250$SIG{TERM} = frèd;
251EXPECT
252You need to quote "frèd" at - line 5.
253########
254# toke.c
255use utf8;
256use open qw( :utf8 :std );
257use warnings 'syntax' ;
258sub ふれど {} ; $SIG{TERM} = ふれど;
259no warnings 'syntax' ;
260$SIG{TERM} = ふれど;
261EXPECT
262You need to quote "ふれど" at - line 5.
263########
264# toke.c
4438c4b7 265use warnings 'syntax' ;
599cee73
PM
266@a[3] = 2;
267@a{3} = 2;
4438c4b7 268no warnings 'syntax' ;
0453d815
PM
269@a[3] = 2;
270@a{3} = 2;
599cee73
PM
271EXPECT
272Scalar value @a[3] better written as $a[3] at - line 3.
273Scalar value @a{3} better written as $a{3} at - line 4.
274########
275# toke.c
b9e186cd
BF
276use utf8;
277use open qw( :utf8 :std );
278use warnings 'syntax' ;
279@à[3] = 2;
280@à{3} = 2;
281no warnings 'syntax' ;
282@à[3] = 2;
283@à{3} = 2;
284EXPECT
285Scalar value @à[3] better written as $à[3] at - line 5.
286Scalar value @à{3} better written as $à{3} at - line 6.
287########
288# toke.c
289use utf8;
290use open qw( :utf8 :std );
291use warnings 'syntax' ;
292@ぁ[3] = 2;
293@ぁ{3} = 2;
294no warnings 'syntax' ;
295@ぁ[3] = 2;
296@ぁ{3} = 2;
297EXPECT
298Scalar value @ぁ[3] better written as $ぁ[3] at - line 5.
299Scalar value @ぁ{3} better written as $ぁ{3} at - line 6.
300########
301# toke.c
4438c4b7 302use warnings 'syntax' ;
599cee73
PM
303$_ = "ab" ;
304s/(ab)/\1/e;
4438c4b7 305no warnings 'syntax' ;
0453d815
PM
306$_ = "ab" ;
307s/(ab)/\1/e;
599cee73
PM
308EXPECT
309Can't use \1 to mean $1 in expression at - line 4.
310########
311# toke.c
4438c4b7 312use warnings 'reserved' ;
599cee73 313$a = abc;
1c3923b3
GS
314$a = { def
315
316=> 1 };
4438c4b7 317no warnings 'reserved' ;
0453d815 318$a = abc;
599cee73
PM
319EXPECT
320Unquoted string "abc" may clash with future reserved word at - line 3.
321########
322# toke.c
e476b1b5 323use warnings 'qw' ;
599cee73 324@a = qw(a, b, c) ;
e476b1b5 325no warnings 'qw' ;
0453d815 326@a = qw(a, b, c) ;
599cee73
PM
327EXPECT
328Possible attempt to separate words with commas at - line 3.
329########
330# toke.c
e476b1b5 331use warnings 'qw' ;
7e03b518 332@a = qw(a b c # #) ;
e476b1b5 333no warnings 'qw' ;
7e03b518 334@a = qw(a b c # #) ;
599cee73
PM
335EXPECT
336Possible attempt to put comments in qw() list at - line 3.
337########
338# toke.c
7e03b518
EB
339use warnings 'qw' ;
340@a = qw(a, b, c # #) ;
341no warnings 'qw' ;
342@a = qw(a, b, c # #) ;
343EXPECT
344Possible attempt to separate words with commas at - line 3.
345Possible attempt to put comments in qw() list at - line 3.
346########
347# toke.c
4438c4b7 348use warnings 'syntax' ;
b1439985
RGS
349print ("");
350print ("") and $x = 1;
351print ("") or die;
352print ("") // die;
353print (1+2) * 3 if 0; # only this one should warn
354print (1+2) if 0;
599cee73 355EXPECT
b1439985 356print (...) interpreted as function at - line 7.
599cee73
PM
357########
358# toke.c
4438c4b7 359no warnings 'syntax' ;
0453d815
PM
360print ("")
361EXPECT
362
363########
364# toke.c
4438c4b7 365use warnings 'syntax' ;
b1439985
RGS
366printf ("");
367printf ("") . '';
599cee73 368EXPECT
b1439985 369printf (...) interpreted as function at - line 4.
599cee73
PM
370########
371# toke.c
4438c4b7 372no warnings 'syntax' ;
0453d815
PM
373printf ("")
374EXPECT
375
376########
377# toke.c
4438c4b7 378use warnings 'syntax' ;
b1439985
RGS
379sort ("");
380sort ("") . '';
599cee73 381EXPECT
b1439985 382sort (...) interpreted as function at - line 4.
599cee73
PM
383########
384# toke.c
4438c4b7 385no warnings 'syntax' ;
0453d815
PM
386sort ("")
387EXPECT
388
389########
390# toke.c
4438c4b7 391use warnings 'ambiguous' ;
599cee73 392$a = ${time[2]};
4438c4b7 393no warnings 'ambiguous' ;
0453d815 394$a = ${time[2]};
599cee73
PM
395EXPECT
396Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
397########
398# toke.c
4438c4b7 399use warnings 'ambiguous' ;
599cee73
PM
400$a = ${time{2}};
401EXPECT
402Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
403########
404# toke.c
4438c4b7 405no warnings 'ambiguous' ;
0453d815
PM
406$a = ${time{2}};
407EXPECT
408
409########
410# toke.c
4438c4b7 411use warnings 'ambiguous' ;
599cee73 412$a = ${time} ;
4438c4b7 413no warnings 'ambiguous' ;
0453d815 414$a = ${time} ;
599cee73
PM
415EXPECT
416Ambiguous use of ${time} resolved to $time at - line 3.
417########
418# toke.c
4438c4b7 419use warnings 'ambiguous' ;
599cee73
PM
420sub fred {}
421$a = ${fred} ;
4438c4b7 422no warnings 'ambiguous' ;
0453d815 423$a = ${fred} ;
599cee73
PM
424EXPECT
425Ambiguous use of ${fred} resolved to $fred at - line 4.
426########
427# toke.c
4438c4b7 428use warnings 'syntax' ;
7fd134d9
JH
429$a = _123; print "$a\n"; #( 3 string)
430$a = 1_23; print "$a\n";
431$a = 12_3; print "$a\n";
432$a = 123_; print "$a\n"; # 6
433$a = _+123; print "$a\n"; # 7 string)
434$a = +_123; print "$a\n"; #( 8 string)
435$a = +1_23; print "$a\n";
436$a = +12_3; print "$a\n";
437$a = +123_; print "$a\n"; # 11
438$a = _-123; print "$a\n"; #(12 string)
439$a = -_123; print "$a\n"; #(13 string)
440$a = -1_23; print "$a\n";
441$a = -12_3; print "$a\n";
442$a = -123_; print "$a\n"; # 16
443$a = 123._456; print "$a\n"; # 17
444$a = 123.4_56; print "$a\n";
445$a = 123.45_6; print "$a\n";
446$a = 123.456_; print "$a\n"; # 20
447$a = +123._456; print "$a\n"; # 21
448$a = +123.4_56; print "$a\n";
449$a = +123.45_6; print "$a\n";
450$a = +123.456_; print "$a\n"; # 24
451$a = -123._456; print "$a\n"; # 25
452$a = -123.4_56; print "$a\n";
453$a = -123.45_6; print "$a\n";
454$a = -123.456_; print "$a\n"; # 28
2bea9a37
JH
455$a = 123.456E_12; printf("%.0f\n", $a); # 29
456$a = 123.456E1_2; printf("%.0f\n", $a);
457$a = 123.456E12_; printf("%.0f\n", $a); # 31
458$a = 123.456E_+12; printf("%.0f\n", $a); # 32
459$a = 123.456E+_12; printf("%.0f\n", $a); # 33
460$a = 123.456E+1_2; printf("%.0f\n", $a);
461$a = 123.456E+12_; printf("%.0f\n", $a); # 35
7fd134d9
JH
462$a = 123.456E_-12; print "$a\n"; # 36
463$a = 123.456E-_12; print "$a\n"; # 37
464$a = 123.456E-1_2; print "$a\n";
465$a = 123.456E-12_; print "$a\n"; # 39
b3b48e3e
JH
466$a = 1__23; print "$a\n"; # 40
467$a = 12.3__4; print "$a\n"; # 41
2bea9a37 468$a = 12.34e1__2; printf("%.0f\n", $a); # 42
4438c4b7 469no warnings 'syntax' ;
7fd134d9
JH
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; print "$a\n";
480$a = -_123; print "$a\n";
481$a = -1_23; print "$a\n";
482$a = -12_3; print "$a\n";
483$a = -123_; print "$a\n";
484$a = 123._456; print "$a\n";
485$a = 123.4_56; print "$a\n";
486$a = 123.45_6; print "$a\n";
487$a = 123.456_; print "$a\n";
488$a = +123._456; print "$a\n";
489$a = +123.4_56; print "$a\n";
490$a = +123.45_6; print "$a\n";
491$a = +123.456_; print "$a\n";
492$a = -123._456; print "$a\n";
493$a = -123.4_56; print "$a\n";
494$a = -123.45_6; print "$a\n";
495$a = -123.456_; print "$a\n";
2bea9a37
JH
496$a = 123.456E_12; printf("%.0f\n", $a);
497$a = 123.456E1_2; printf("%.0f\n", $a);
498$a = 123.456E12_; printf("%.0f\n", $a);
499$a = 123.456E_+12; printf("%.0f\n", $a);
500$a = 123.456E+_12; printf("%.0f\n", $a);
501$a = 123.456E+1_2; printf("%.0f\n", $a);
502$a = 123.456E+12_; printf("%.0f\n", $a);
7fd134d9
JH
503$a = 123.456E_-12; print "$a\n";
504$a = 123.456E-_12; print "$a\n";
505$a = 123.456E-1_2; print "$a\n";
506$a = 123.456E-12_; print "$a\n";
b3b48e3e
JH
507$a = 1__23; print "$a\n";
508$a = 12.3__4; print "$a\n";
2bea9a37 509$a = 12.34e1__2; printf("%.0f\n", $a);
599cee73 510EXPECT
fbfa96bd 511OPTIONS regex
928753ea 512Misplaced _ in number at - line 6.
928753ea 513Misplaced _ in number at - line 11.
7fd134d9 514Misplaced _ in number at - line 16.
928753ea 515Misplaced _ in number at - line 17.
7fd134d9 516Misplaced _ in number at - line 20.
928753ea 517Misplaced _ in number at - line 21.
7fd134d9
JH
518Misplaced _ in number at - line 24.
519Misplaced _ in number at - line 25.
520Misplaced _ in number at - line 28.
521Misplaced _ in number at - line 29.
522Misplaced _ in number at - line 31.
523Misplaced _ in number at - line 32.
524Misplaced _ in number at - line 33.
525Misplaced _ in number at - line 35.
526Misplaced _ in number at - line 36.
527Misplaced _ in number at - line 37.
528Misplaced _ in number at - line 39.
b3b48e3e
JH
529Misplaced _ in number at - line 40.
530Misplaced _ in number at - line 41.
531Misplaced _ in number at - line 42.
928753ea
JH
532_123
533123
928753ea 534123
7fd134d9
JH
535123
536123
537_123
538123
539123
540123
541-123
542-_123
543-123
544-123
545-123
546123.456
547123.456
548123.456
549123.456
550123.456
551123.456
552123.456
553123.456
554-123.456
555-123.456
556-123.456
557-123.456
558123456000000000
559123456000000000
560123456000000000
561123456000000000
562123456000000000
563123456000000000
564123456000000000
fbfa96bd
NIS
5651.23456e-0?10
5661.23456e-0?10
5671.23456e-0?10
5681.23456e-0?10
b3b48e3e
JH
569123
57012.34
57112340000000000
7fd134d9
JH
572_123
573123
574123
575123
576123
577_123
578123
579123
580123
581-123
582-_123
583-123
584-123
585-123
586123.456
587123.456
588123.456
589123.456
590123.456
928753ea
JH
591123.456
592123.456
928753ea 593123.456
7fd134d9
JH
594-123.456
595-123.456
596-123.456
597-123.456
598123456000000000
599123456000000000
600123456000000000
601123456000000000
602123456000000000
603123456000000000
604123456000000000
fbfa96bd
NIS
6051.23456e-0?10
6061.23456e-0?10
6071.23456e-0?10
6081.23456e-0?10
b3b48e3e
JH
609123
61012.34
61112340000000000
599cee73
PM
612########
613# toke.c
e476b1b5 614use warnings 'bareword' ;
60e6418e 615#line 25 "bar"
599cee73 616$a = FRED:: ;
e476b1b5 617no warnings 'bareword' ;
0453d815
PM
618#line 25 "bar"
619$a = FRED:: ;
599cee73 620EXPECT
60e6418e 621Bareword "FRED::" refers to nonexistent package at bar line 25.
979a1401
BF
622########
623# toke.c
624use utf8;
625use open qw( :utf8 :std );
626use warnings 'bareword' ;
627#line 25 "bar"
628$a = FRÈD:: ;
629no warnings 'bareword' ;
630#line 25 "bar"
631$a = FRÈD:: ;
632EXPECT
633Bareword "FRÈD::" refers to nonexistent package at bar line 25.
634########
635# toke.c
636use utf8;
637use open qw( :utf8 :std );
638use warnings 'bareword' ;
639#line 25 "bar"
640$a = ϞϞϞ:: ;
641no warnings 'bareword' ;
642#line 25 "bar"
643$a = ϞϞϞ:: ;
644EXPECT
645Bareword "ϞϞϞ::" refers to nonexistent package at bar line 25.
599cee73
PM
646########
647# toke.c
4438c4b7 648use warnings 'ambiguous' ;
599cee73 649sub time {}
0453d815 650my $a = time() ;
4438c4b7 651no warnings 'ambiguous' ;
0453d815 652my $b = time() ;
599cee73
PM
653EXPECT
654Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
655########
656# toke.c
26d16222 657use warnings ;
0453d815 658eval <<'EOE';
df0deb90
GS
659# line 30 "foo"
660warn "yelp";
0453d815 661{
0453d815
PM
662 $_ = " \x{123} " ;
663}
664EOE
665EXPECT
df0deb90 666yelp at foo line 30.
0453d815
PM
667########
668# toke.c
0453d815 669my $a = rand + 4 ;
fbdd83da
DIM
670$a = rand *^H ;
671$a = rand $^H ;
0453d815 672EXPECT
2d5ccbba 673Warning: Use of "rand" without parentheses is ambiguous at - line 2.
0453d815
PM
674########
675# toke.c
676$^W = 0 ;
677my $a = rand + 4 ;
678{
4438c4b7 679 no warnings 'ambiguous' ;
0453d815 680 $a = rand + 4 ;
4438c4b7 681 use warnings 'ambiguous' ;
0453d815
PM
682 $a = rand + 4 ;
683}
684$a = rand + 4 ;
685EXPECT
2d5ccbba
IT
686Warning: Use of "rand" without parentheses is ambiguous at - line 3.
687Warning: Use of "rand" without parentheses is ambiguous at - line 8.
688Warning: Use of "rand" without parentheses is ambiguous at - line 10.
0453d815 689########
e19a021b
FC
690# [perl #97110]
691sub myrand(;$) { }
b5fb7ce3 692sub whatever($) { }
e19a021b 693my $a = myrand + 4 ;
b5fb7ce3 694my $b = whatever + 4 ;
e19a021b 695EXPECT
b5fb7ce3 696Warning: Use of "myrand" without parentheses is ambiguous at - line 4.
e19a021b 697########
0453d815 698# toke.c
e8ae98db
RGS
699use warnings "ambiguous";
700print for keys %+; # should not warn
701EXPECT
702########
703# toke.c
0453d815
PM
704sub fred {};
705-fred ;
706EXPECT
707Ambiguous use of -fred resolved as -&fred() at - line 3.
708########
709# toke.c
710$^W = 0 ;
711sub fred {} ;
712-fred ;
713{
4438c4b7 714 no warnings 'ambiguous' ;
0453d815 715 -fred ;
4438c4b7 716 use warnings 'ambiguous' ;
0453d815
PM
717 -fred ;
718}
719-fred ;
720EXPECT
721Ambiguous use of -fred resolved as -&fred() at - line 4.
722Ambiguous use of -fred resolved as -&fred() at - line 9.
723Ambiguous use of -fred resolved as -&fred() at - line 11.
724########
725# toke.c
43b5ab4c
BF
726use utf8;
727use open qw( :utf8 :std );
728sub frèd {};
729-frèd ;
730EXPECT
731Ambiguous use of -frèd resolved as -&frèd() at - line 5.
732########
733# toke.c
734$^W = 0 ;
735use utf8;
736use open qw( :utf8 :std );
737sub frèd {} ;
738-frèd ;
739{
740 no warnings 'ambiguous' ;
741 -frèd ;
742 use warnings 'ambiguous' ;
743 -frèd ;
744}
745-frèd ;
746EXPECT
747Ambiguous use of -frèd resolved as -&frèd() at - line 6.
748Ambiguous use of -frèd resolved as -&frèd() at - line 11.
749Ambiguous use of -frèd resolved as -&frèd() at - line 13.
750########
751# toke.c
752use utf8;
753use open qw( :utf8 :std );
754sub ᒍᒘᒊ {};
755-ᒍᒘᒊ ;
756EXPECT
757Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 5.
758########
759# toke.c
760$^W = 0 ;
761use utf8;
762use open qw( :utf8 :std );
763sub ᒍᒘᒊ {} ;
764-ᒍᒘᒊ ;
765{
766 no warnings 'ambiguous' ;
767 -ᒍᒘᒊ ;
768 use warnings 'ambiguous' ;
769 -ᒍᒘᒊ ;
770}
771-ᒍᒘᒊ ;
772EXPECT
773Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 6.
774Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 11.
775Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 13.
776########
777# toke.c
0453d815 778open FOO || time;
240d1b6f 779open local *FOO; # should be ok
0453d815
PM
780EXPECT
781Precedence problem: open FOO should be open(FOO) at - line 2.
782########
71aa9713
BF
783# toke.c
784use utf8;
785use open qw( :utf8 :std );
786open FÒÒ || time;
787EXPECT
788Precedence problem: open FÒÒ should be open(FÒÒ) at - line 4.
789########
790# toke.c
791use utf8;
792use open qw( :utf8 :std );
793open ᒍOO || time;
794EXPECT
795Precedence problem: open ᒍOO should be open(ᒍOO) at - line 4.
796########
66fbe8fb
HS
797# toke.c (and [perl #16184])
798open FOO => "<&0"; close FOO;
799EXPECT
800########
0453d815
PM
801# toke.c
802$^W = 0 ;
803open FOO || time;
804{
e476b1b5 805 no warnings 'precedence' ;
0453d815 806 open FOO || time;
e476b1b5 807 use warnings 'precedence' ;
0453d815
PM
808 open FOO || time;
809}
810open FOO || time;
db3abe52 811open Foo::BAR; # this should not warn
0453d815
PM
812EXPECT
813Precedence problem: open FOO should be open(FOO) at - line 3.
814Precedence problem: open FOO should be open(FOO) at - line 8.
815Precedence problem: open FOO should be open(FOO) at - line 10.
816########
817# toke.c
818$^W = 0 ;
71aa9713
BF
819use utf8;
820use open qw( :utf8 :std );
821open FÒÒ || time;
822{
823 no warnings 'precedence' ;
824 open FÒÒ || time;
825 use warnings 'precedence' ;
826 open FÒÒ || time;
827}
828open FÒÒ || time;
829EXPECT
830Precedence problem: open FÒÒ should be open(FÒÒ) at - line 5.
831Precedence problem: open FÒÒ should be open(FÒÒ) at - line 10.
832Precedence problem: open FÒÒ should be open(FÒÒ) at - line 12.
833########
834# toke.c
835use utf8;
836use open qw( :utf8 :std );
837$^W = 0 ;
838open ᒍÒÒ || time;
839{
840 no warnings 'precedence' ;
841 open ᒍÒÒ || time;
842 use warnings 'precedence' ;
843 open ᒍÒÒ || time;
844}
845open ᒍÒÒ || time;
846EXPECT
847Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 5.
848Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 10.
849Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 12.
850########
851# toke.c
852$^W = 0 ;
0453d815
PM
853*foo *foo ;
854{
4438c4b7 855 no warnings 'ambiguous' ;
0453d815 856 *foo *foo ;
4438c4b7 857 use warnings 'ambiguous' ;
0453d815
PM
858 *foo *foo ;
859}
860*foo *foo ;
861EXPECT
862Operator or semicolon missing before *foo at - line 3.
863Ambiguous use of * resolved as operator * at - line 3.
864Operator or semicolon missing before *foo at - line 8.
865Ambiguous use of * resolved as operator * at - line 8.
866Operator or semicolon missing before *foo at - line 10.
867Ambiguous use of * resolved as operator * at - line 10.
767a6a26
PM
868########
869# toke.c
02571fe8
BF
870use utf8;
871use open qw( :utf8 :std );
872$^W = 0 ;
873*foo *foo ;
874{
875 no warnings 'ambiguous' ;
876 *foo *foo ;
877 use warnings 'ambiguous' ;
878 *foo *foo ;
879}
880*foo *foo ;
881EXPECT
882Operator or semicolon missing before *foo at - line 5.
883Ambiguous use of * resolved as operator * at - line 5.
884Operator or semicolon missing before *foo at - line 10.
885Ambiguous use of * resolved as operator * at - line 10.
886Operator or semicolon missing before *foo at - line 12.
887Ambiguous use of * resolved as operator * at - line 12.
888########
889# toke.c
e476b1b5 890use warnings 'misc' ;
767a6a26 891my $a = "\m" ;
e476b1b5 892no warnings 'misc' ;
767a6a26
PM
893$a = "\m" ;
894EXPECT
895Unrecognized escape \m passed through at - line 3.
896########
897# toke.c
52ed07f6
BF
898use warnings 'misc' ;
899my $a = "abcd\E" ;
900no warnings 'misc' ;
901$a = "abcd\E" ;
902EXPECT
820438b1 903Useless use of \E at - line 3.
52ed07f6
BF
904########
905# toke.c
767a6a26
PM
906use warnings 'portable' ;
907my $a = 0b011111111111111111111111111111110 ;
908 $a = 0b011111111111111111111111111111111 ;
909 $a = 0b111111111111111111111111111111111 ;
910 $a = 0x0fffffffe ;
911 $a = 0x0ffffffff ;
912 $a = 0x1ffffffff ;
913 $a = 0037777777776 ;
914 $a = 0037777777777 ;
915 $a = 0047777777777 ;
916no warnings 'portable' ;
917 $a = 0b011111111111111111111111111111110 ;
918 $a = 0b011111111111111111111111111111111 ;
919 $a = 0b111111111111111111111111111111111 ;
920 $a = 0x0fffffffe ;
921 $a = 0x0ffffffff ;
922 $a = 0x1ffffffff ;
923 $a = 0037777777776 ;
924 $a = 0037777777777 ;
925 $a = 0047777777777 ;
926EXPECT
927Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
928Hexadecimal number > 0xffffffff non-portable at - line 8.
929Octal number > 037777777777 non-portable at - line 11.
930########
931# toke.c
932use warnings 'overflow' ;
933my $a = 0b011111111111111111111111111111110 ;
934 $a = 0b011111111111111111111111111111111 ;
15041a67 935 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
936 $a = 0x0fffffffe ;
937 $a = 0x0ffffffff ;
15041a67 938 $a = 0x10000000000000000 ;
767a6a26
PM
939 $a = 0037777777776 ;
940 $a = 0037777777777 ;
15041a67 941 $a = 002000000000000000000000;
767a6a26
PM
942no warnings 'overflow' ;
943 $a = 0b011111111111111111111111111111110 ;
944 $a = 0b011111111111111111111111111111111 ;
15041a67 945 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
946 $a = 0x0fffffffe ;
947 $a = 0x0ffffffff ;
15041a67 948 $a = 0x10000000000000000 ;
767a6a26
PM
949 $a = 0037777777776 ;
950 $a = 0037777777777 ;
15041a67 951 $a = 002000000000000000000000;
767a6a26
PM
952EXPECT
953Integer overflow in binary number at - line 5.
954Integer overflow in hexadecimal number at - line 8.
955Integer overflow in octal number at - line 11.
8593bda5
GS
956########
957# toke.c
ac206dc8
RGS
958BEGIN { $^C = 1; }
959use warnings 'misc';
960dump;
961CORE::dump;
962EXPECT
963dump() better written as CORE::dump() at - line 4.
964- syntax OK
965########
966# toke.c
967use warnings 'misc';
968use subs qw/dump/;
93f09d7b 969sub dump { print "no warning for overridden dump\n"; }
ac206dc8
RGS
970dump;
971EXPECT
93f09d7b 972no warning for overridden dump
ac206dc8
RGS
973########
974# toke.c
8593bda5
GS
975use warnings 'ambiguous';
976"@mjd_previously_unused_array";
977no warnings 'ambiguous';
29fb1d0e 978"@mjd_previously_unused_array2";
8593bda5
GS
979EXPECT
980Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.
707afd92
MS
981########
982# toke.c
29fb1d0e
BF
983use utf8;
984use open qw( :utf8 :std );
985use warnings 'ambiguous';
986"@mjd_previously_unused_àrray";
987no warnings 'ambiguous';
988"@mjd_previously_unused_àrray2";
989EXPECT
990Possible unintended interpolation of @mjd_previously_unused_àrray in string at - line 5.
991########
992# toke.c
993use utf8;
994use open qw( :utf8 :std );
995use warnings 'ambiguous';
996"@mjd_previously_unused_ぁrrぁy";
997no warnings 'ambiguous';
998"@mjd_previously_unused_ぁrrぁy2";
999EXPECT
1000Possible unintended interpolation of @mjd_previously_unused_ぁrrぁy in string at - line 5.
1001########
1002# toke.c
d8c55666 1003# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
1004use warnings 'regexp';
1005"foo" =~ /foo/c;
64e578a2 1006"foo" =~ /foo/cg;
4ac733c9
MJD
1007no warnings 'regexp';
1008"foo" =~ /foo/c;
64e578a2 1009"foo" =~ /foo/cg;
4ac733c9
MJD
1010EXPECT
1011Use of /c modifier is meaningless without /g at - line 4.
1012########
1013# toke.c
d8c55666 1014# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
1015use warnings 'regexp';
1016$_ = "ab" ;
1017s/ab/ab/c;
64e578a2 1018s/ab/ab/cg;
4ac733c9
MJD
1019no warnings 'regexp';
1020s/ab/ab/c;
64e578a2 1021s/ab/ab/cg;
4ac733c9 1022EXPECT
64e578a2
MJD
1023Use of /c modifier is meaningless in s/// at - line 5.
1024Use of /c modifier is meaningless in s/// at - line 6.
d8c55666
MJD
1025########
1026-wa
1027# toke.c
1028# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
1029print "@F\n";
1030EXPECT
1031
1032########
1033-w
1034# toke.c
1035# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
1036print "@F\n";
1037EXPECT
1038Possible unintended interpolation of @F in string at - line 4.
1039Name "main::F" used only once: possible typo at - line 4.
1040########
1041-wa
1042# toke.c
1043# 20020414 mjd-perl-patch+@plover.com
1044EXPECT
1045
2710853f
MJD
1046########
1047# toke.c
1048# 20020414 mjd-perl-patch+@plover.com
1049# In 5.7.3, this emitted "Possible unintended interpolation" warnings
1050use warnings 'ambiguous';
1051$s = "(@-)(@+)";
1052EXPECT
1053
56da5a46
RGS
1054########
1055# toke.c
1056# mandatory warning
1057eval q/if ($a) { } elseif ($b) { }/;
1058no warnings "syntax";
1059eval q/if ($a) { } elseif ($b) { }/;
1060EXPECT
1061elseif should be elsif at (eval 1) line 1.
1062########
1063# toke.c
1064# mandatory warning
1065eval q/5 6/;
1066no warnings "syntax";
1067eval q/5 6/;
1068EXPECT
1069Number found where operator expected at (eval 1) line 1, near "5 6"
1070 (Missing operator before 6?)
984200d0
YST
1071########
1072# toke.c
1073use warnings "syntax";
1074$_ = $a = 1;
1075$a !=~ /1/;
1076$a !=~ m#1#;
1077$a !=~/1/;
1078$a !=~ ?/?;
decca21c
YST
1079$a !=~ y/1//;
1080$a !=~ tr/1//;
1081$a !=~ s/1//;
984200d0
YST
1082$a != ~/1/;
1083no warnings "syntax";
1084$a !=~ /1/;
1085$a !=~ m#1#;
1086$a !=~/1/;
1087$a !=~ ?/?;
decca21c
YST
1088$a !=~ y/1//;
1089$a !=~ tr/1//;
1090$a !=~ s/1//;
984200d0
YST
1091EXPECT
1092!=~ should be !~ at - line 4.
1093!=~ should be !~ at - line 5.
1094!=~ should be !~ at - line 6.
1095!=~ should be !~ at - line 7.
decca21c
YST
1096!=~ should be !~ at - line 8.
1097!=~ should be !~ at - line 9.
1098!=~ should be !~ at - line 10.
1108974d
RGS
1099########
1100# toke.c
1101our $foo :unique;
8e5dadda
NC
1102sub pam :locked;
1103sub glipp :locked {
1104}
1105sub whack_eth ($) : locked {
1106}
d1d15184 1107no warnings 'deprecated';
1108974d 1108our $bar :unique;
8e5dadda
NC
1109sub zapeth :locked;
1110sub ker_plop :locked {
1111}
1112sub swa_a_p ($) : locked {
1113}
1108974d 1114EXPECT
d1d15184
NC
1115Use of :unique is deprecated at - line 2.
1116Use of :locked is deprecated at - line 3.
1117Use of :locked is deprecated at - line 4.
1118Use of :locked is deprecated at - line 6.
9e8d7757
RB
1119########
1120# toke.c
1121use warnings "syntax";
1122sub proto_after_array(@$);
1123sub proto_after_arref(\@$);
1124sub proto_after_arref2(\[@$]);
1125sub proto_after_arref3(\[@$]_);
1126sub proto_after_hash(%$);
1127sub proto_after_hashref(\%$);
1128sub proto_after_hashref2(\[%$]);
1129sub underscore_last_pos($_);
1130sub underscore2($_;$);
1131sub underscore_fail($_$);
1132sub underscore_after_at(@_);
1133no warnings "syntax";
1134sub proto_after_array(@$);
1135sub proto_after_hash(%$);
1136sub underscore_fail($_$);
1137EXPECT
1138Prototype after '@' for main::proto_after_array : @$ at - line 3.
1139Prototype after '%' for main::proto_after_hash : %$ at - line 7.
aef2a98a 1140Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12.
9e8d7757 1141Prototype after '@' for main::underscore_after_at : @_ at - line 13.
77772344
B
1142########
1143# toke.c
1144use warnings "ambiguous";
1145"foo\nn" =~ /^foo$\n/;
1146"foo\nn" =~ /^foo${\}n/;
1147my $foo = qr/^foo$\n/;
1148my $bar = qr/^foo${\}n/;
1149no warnings "ambiguous";
1150"foo\nn" =~ /^foo$\n/;
1151"foo\nn" =~ /^foo${\}n/;
1152my $foo = qr/^foo$\n/;
1153my $bar = qr/^foo${\}n/;
1154EXPECT
1155Possible unintended interpolation of $\ in regex at - line 3.
1156Possible unintended interpolation of $\ in regex at - line 5.
d83f38d8
NC
1157########
1158# toke.c
f0a2b745
KW
1159use warnings 'syntax' ;
1160my $a = "\o";
1161my $a = "\o{";
1162my $a = "\o{}";
1163no warnings 'syntax' ;
1164my $a = "\o";
1165my $a = "\o{";
1166my $a = "\o{}";
1167EXPECT
1168Missing braces on \o{} at - line 3, within string
1169Missing right brace on \o{ at - line 4, within string
1170Number with no digits at - line 5, within string
1171BEGIN not safe after errors--compilation aborted at - line 6.
1172########
1173# toke.c
1174use warnings 'digit' ;
1175my $a = "\o{1238456}";
1176no warnings 'digit' ;
1177my $a = "\o{1238456}";
1178EXPECT
1179Non-octal character '8'. Resolved as "\o{123}" at - line 3.
725a61d7
Z
1180########
1181# toke.c
1182use warnings;
1183my $a = "foo";
1184print $a =~ ?f? ? "yes\n" : "no\n" foreach 0..2;
1185EXPECT
1186Use of ?PATTERN? without explicit operator is deprecated at - line 4.
1187yes
1188no
1189no
17a3df4c
KW
1190########
1191# toke.c
1192use warnings;
1193my $a = "\c{ack}";
1194$a = "\c,";
1195$a = "\c`";
1196no warnings 'syntax';
1197$a = "\c{ack}";
1198$a = "\c,";
1199$a = "\c`";
1200no warnings 'deprecated';
1201EXPECT
1202"\c{" is deprecated and is more clearly written as ";" at - line 3.
1203"\c," is more clearly written simply as "l" at - line 4.
1204"\c`" is more clearly written simply as "\ " at - line 5.
1205"\c{" is deprecated and is more clearly written as ";" at - line 7.
3955e1a9
KW
1206########
1207# toke.c
1208use warnings 'syntax' ;
1209my $a = qr/foo/du;
ff3f26d2 1210$a = qr/foo/lai;
3955e1a9 1211$a = qr/foo/lil;
ff3f26d2
KW
1212$a = qr/foo/aia;
1213$a = qr/foo/aaia;
3955e1a9
KW
1214no warnings 'syntax' ;
1215my $a = qr/foo/du;
1216EXPECT
1217Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= "
1218Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= "
1219Regexp modifier "/l" may not appear twice at - line 5, near "= "
ff3f26d2
KW
1220Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= "
1221BEGIN not safe after errors--compilation aborted at - line 8.
ba05d9aa
FC
1222########
1223# toke.c
1224# [perl #4362]
1225eval "print q\xabfoo";
1226print "ok\n" if
1227 $@ =~ /Can't find string terminator "\xab" anywhere before EOF/;
1228EXPECT
1229ok
5c66c3dd
BF
1230########
1231# toke.c
1232use utf8;
1233use open qw( :utf8 :std );
1234use warnings 'ambiguous' ;
1235sub frèd {}
1236$a = ${frèd} ;
1237no warnings 'ambiguous' ;
1238$a = ${frèd} ;
1239EXPECT
1240Ambiguous use of ${frèd} resolved to $frèd at - line 6.
1241########
1242# toke.c
1243use utf8;
1244use open qw( :utf8 :std );
1245use warnings 'ambiguous' ;
1246sub f렏 {}
1247$a = ${f렏} ;
1248no warnings 'ambiguous' ;
1249$a = ${f렏} ;
1250EXPECT
1251Ambiguous use of ${f렏} resolved to $f렏 at - line 6.
3773592b
BF
1252########
1253# toke.c
1254use utf8;
1255use open qw( :utf8 :std );
1256use warnings;
1257CORE::렏;
1258EXPECT
1259CORE::렏 is not a keyword at - line 5.