This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Allow ->@ ->$ interpolation under postderef_qq feature
[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
599cee73
PM
38 Can't use \\%c to mean $%c in expression
39 $_ = "ab" ; s/(ab)/\1/e;
40
41 Unquoted string "abc" may clash with future reserved word at - line 3.
42 warn(warn_reserved
43 $a = abc;
44
599cee73
PM
45 Possible attempt to separate words with commas
46 @a = qw(a, b, c) ;
47
48 Possible attempt to put comments in qw() list
49 @a = qw(a b # c) ;
50
599cee73
PM
51 %s (...) interpreted as function
52 print ("")
53 printf ("")
54 sort ("")
55
56 Ambiguous use of %c{%s%s} resolved to %c%s%s
57 $a = ${time[2]}
58 $a = ${time{2}}
59
60
61 Ambiguous use of %c{%s} resolved to %c%s
62 $a = ${time}
63 sub fred {} $a = ${fred}
64
65 Misplaced _ in number
66 $a = 1_2;
67 $a = 1_2345_6;
68
69 Bareword \"%s\" refers to nonexistent package
70 $a = FRED:: ;
71
72 Ambiguous call resolved as CORE::%s(), qualify as such or use &
73 sub time {}
74 my $a = time()
75
767a6a26
PM
76 Unrecognized escape \\%c passed through
77 $a = "\m" ;
78
820438b1 79 Useless use of \\E.
52ed07f6
BF
80 $a = "abcd\E" ;
81
767a6a26
PM
82 %s number > %s non-portable
83 my $a = 0b011111111111111111111111111111110 ;
84 $a = 0b011111111111111111111111111111111 ;
85 $a = 0b111111111111111111111111111111111 ;
86 $a = 0x0fffffffe ;
87 $a = 0x0ffffffff ;
88 $a = 0x1ffffffff ;
89 $a = 0037777777776 ;
90 $a = 0037777777777 ;
91 $a = 0047777777777 ;
92
93 Integer overflow in binary number
94 my $a = 0b011111111111111111111111111111110 ;
95 $a = 0b011111111111111111111111111111111 ;
96 $a = 0b111111111111111111111111111111111 ;
97 $a = 0x0fffffffe ;
98 $a = 0x0ffffffff ;
99 $a = 0x1ffffffff ;
100 $a = 0037777777776 ;
101 $a = 0037777777777 ;
102 $a = 0047777777777 ;
ac206dc8
RGS
103
104 dump() better written as CORE::dump()
4ac733c9
MJD
105
106 Use of /c modifier is meaningless without /g
107
64e578a2
MJD
108 Use of /c modifier is meaningless in s///
109
0453d815
PM
110 Mandatory Warnings
111 ------------------
112 Use of "%s" without parentheses is ambiguous [check_uni]
113 rand + 4
114
115 Ambiguous use of -%s resolved as -&%s() [yylex]
116 sub fred {} ; - fred ;
117
118 Precedence problem: open %.*s should be open(%.*s) [yylex]
119 open FOO || die;
120
121 Operator or semicolon missing before %c%s [yylex]
122 Ambiguous use of %c resolved as operator %c
123 *foo *foo
124
599cee73
PM
125__END__
126# toke.c
599cee73
PM
127format STDOUT =
128@<<< @||| @>>> @>>>
129$a $b "abc" 'def'
130.
4438c4b7 131no warnings 'deprecated' ;
0453d815
PM
132format STDOUT =
133@<<< @||| @>>> @>>>
134$a $b "abc" 'def'
135.
599cee73 136EXPECT
d1d15184
NC
137Use of comma-less variable list is deprecated at - line 4.
138Use of comma-less variable list is deprecated at - line 4.
139Use of comma-less variable list is deprecated at - line 4.
599cee73
PM
140########
141# toke.c
599cee73
PM
142$a = <<;
143
4438c4b7 144no warnings 'deprecated' ;
0453d815
PM
145$a = <<;
146
599cee73 147EXPECT
0da72d5e
KW
148Use of bare << to mean <<"" is deprecated at - line 2.
149########
150# toke.c
b29f65fc
BF
151eval "\$\cT";
152eval "\${\7LOBAL_PHASE}";
153eval "\${\cT}";
154eval "\${\n\cT}";
155eval "\${\cT\n}";
156my $ret = eval "\${\n\cT\n}";
157print "ok\n" if $ret == $^T;
158
159no warnings 'deprecated' ;
160eval "\$\cT";
161eval "\${\7LOBAL_PHASE}";
162eval "\${\cT}";
163eval "\${\n\cT}";
164eval "\${\cT\n}";
165eval "\${\n\cT\n}";
166
167EXPECT
168Use of literal control characters in variable names is deprecated at (eval 1) line 1.
169Use of literal control characters in variable names is deprecated at (eval 2) line 1.
170Use of literal control characters in variable names is deprecated at (eval 3) line 1.
a49b10d0 171Use of literal control characters in variable names is deprecated at (eval 4) line 2.
b29f65fc 172Use of literal control characters in variable names is deprecated at (eval 5) line 1.
a49b10d0 173Use of literal control characters in variable names is deprecated at (eval 6) line 2.
b29f65fc
BF
174ok
175########
176# toke.c
0da72d5e
KW
177$a =~ m/$foo/eq;
178$a =~ s/$foo/fool/seq;
179
180EXPECT
181OPTION fatal
182Unknown regexp modifier "/e" at - line 2, near "=~ "
183Unknown regexp modifier "/q" at - line 2, near "=~ "
184Unknown regexp modifier "/q" at - line 3, near "=~ "
185Execution of - aborted due to compilation errors.
84159251
BF
186########
187# toke.c
188use utf8;
189use open qw( :utf8 :std );
190$a =~ m/$foo/eネq;
191$a =~ s/$foo/fool/seネq;
192
193EXPECT
194OPTION fatal
195Unknown regexp modifier "/e" at - line 4, near "=~ "
196Unknown regexp modifier "/ネ" at - line 4, near "=~ "
197Unknown regexp modifier "/q" at - line 4, near "=~ "
198Unknown regexp modifier "/ネ" at - line 5, near "=~ "
199Unknown regexp modifier "/q" at - line 5, near "=~ "
200Execution of - aborted due to compilation errors.
599cee73
PM
201########
202# toke.c
4438c4b7 203use warnings 'syntax' ;
599cee73 204s/(abc)/\1/;
4438c4b7 205no warnings 'syntax' ;
0453d815 206s/(abc)/\1/;
599cee73
PM
207EXPECT
208\1 better written as $1 at - line 3.
209########
210# toke.c
4438c4b7 211use warnings 'semicolon' ;
599cee73
PM
212$a = 1
213&time ;
4438c4b7 214no warnings 'semicolon' ;
0453d815
PM
215$a = 1
216&time ;
599cee73
PM
217EXPECT
218Semicolon seems to be missing at - line 3.
219########
220# toke.c
4438c4b7 221use warnings 'syntax' ;
599cee73
PM
222my $a =+ 2 ;
223$a =- 2 ;
224$a =* 2 ;
225$a =% 2 ;
226$a =& 2 ;
227$a =. 2 ;
228$a =^ 2 ;
229$a =| 2 ;
230$a =< 2 ;
231$a =/ 2 ;
232EXPECT
7f01dc7a
JH
233Reversed += operator at - line 3.
234Reversed -= operator at - line 4.
235Reversed *= operator at - line 5.
236Reversed %= operator at - line 6.
237Reversed &= operator at - line 7.
238Reversed .= operator at - line 8.
239Reversed ^= operator at - line 9.
240Reversed |= operator at - line 10.
241Reversed <= operator at - line 11.
242syntax error at - line 8, near "=."
243syntax error at - line 9, near "=^"
244syntax error at - line 10, near "=|"
245Unterminated <> operator at - line 11.
599cee73
PM
246########
247# toke.c
4438c4b7 248no warnings 'syntax' ;
0453d815
PM
249my $a =+ 2 ;
250$a =- 2 ;
251$a =* 2 ;
252$a =% 2 ;
253$a =& 2 ;
254$a =. 2 ;
255$a =^ 2 ;
256$a =| 2 ;
257$a =< 2 ;
258$a =/ 2 ;
259EXPECT
7f01dc7a
JH
260syntax error at - line 8, near "=."
261syntax error at - line 9, near "=^"
262syntax error at - line 10, near "=|"
263Unterminated <> operator at - line 11.
0453d815
PM
264########
265# toke.c
4438c4b7 266use warnings 'syntax' ;
599cee73 267my $a = $a[1,2] ;
4438c4b7 268no warnings 'syntax' ;
0453d815 269my $a = $a[1,2] ;
599cee73
PM
270EXPECT
271Multidimensional syntax $a[1,2] not supported at - line 3.
272########
273# toke.c
4438c4b7 274use warnings 'syntax' ;
599cee73 275sub fred {} ; $SIG{TERM} = fred;
4438c4b7 276no warnings 'syntax' ;
0453d815 277$SIG{TERM} = fred;
599cee73
PM
278EXPECT
279You need to quote "fred" at - line 3.
280########
281# toke.c
4c01a014
BF
282use utf8;
283use open qw( :utf8 :std );
284use warnings 'syntax' ;
285sub frèd {} ; $SIG{TERM} = frèd;
286no warnings 'syntax' ;
287$SIG{TERM} = frèd;
288EXPECT
289You need to quote "frèd" at - line 5.
290########
291# toke.c
292use utf8;
293use open qw( :utf8 :std );
294use warnings 'syntax' ;
295sub ふれど {} ; $SIG{TERM} = ふれど;
296no warnings 'syntax' ;
297$SIG{TERM} = ふれど;
298EXPECT
299You need to quote "ふれど" at - line 5.
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
a49b10d0
BF
405use warnings 'ambiguous' ;
406$a = ${
407
408 time
409 {2}
410};
411warn "after";
412EXPECT
413Ambiguous use of ${time{...}} resolved to $time{...} at - line 5.
414after at - line 8.
415########
416# toke.c
417use warnings 'ambiguous' ;
418$a = ${
419
420time[2]
421
422};
423$a = ${
424
425time
426 [2]
427
428};
429warn "after";
430EXPECT
431Ambiguous use of ${time[...]} resolved to $time[...] at - line 5.
432Ambiguous use of ${time[...]} resolved to $time[...] at - line 10.
433after at - line 14.
434########
435# toke.c
4438c4b7 436no warnings 'ambiguous' ;
0453d815
PM
437$a = ${time{2}};
438EXPECT
439
440########
441# toke.c
4438c4b7 442use warnings 'ambiguous' ;
599cee73 443$a = ${time} ;
27ffb73a
NC
444$a = @{time} ;
445$a = $#{time} ; # This one is special cased in toke.c
446$a = %{time} ;
447$a = *{time} ;
448$a = defined &{time} ; # To avoid calling &::time
4438c4b7 449no warnings 'ambiguous' ;
0453d815 450$a = ${time} ;
27ffb73a
NC
451$a = @{time} ;
452$a = $#{time} ; # This one is special cased in toke.c
453$a = %{time} ;
454$a = *{time} ;
455$a = defined &{time} ; # To avoid calling &::time
599cee73
PM
456EXPECT
457Ambiguous use of ${time} resolved to $time at - line 3.
27ffb73a
NC
458Ambiguous use of @{time} resolved to @time at - line 4.
459Ambiguous use of @{time} resolved to @time at - line 5.
460Ambiguous use of %{time} resolved to %time at - line 6.
461Ambiguous use of *{time} resolved to *time at - line 7.
462Ambiguous use of &{time} resolved to &time at - line 8.
599cee73
PM
463########
464# toke.c
4438c4b7 465use warnings 'ambiguous' ;
a49b10d0
BF
466$a = ${
467time
468} ;
469$a = @{
470time
471} ;
472$a = $#{
473time
474} ;
475$a = %{
476time
477} ;
478$a = *{
479time
480} ;
481$a = defined &{
482time
483
484
485} ;
486warn "last";
487EXPECT
488Ambiguous use of ${time} resolved to $time at - line 4.
489Ambiguous use of @{time} resolved to @time at - line 7.
490Ambiguous use of @{time} resolved to @time at - line 10.
491Ambiguous use of %{time} resolved to %time at - line 13.
492Ambiguous use of *{time} resolved to *time at - line 16.
493Ambiguous use of &{time} resolved to &time at - line 19.
494last at - line 23.
495########
496# toke.c
497use warnings 'ambiguous' ;
599cee73
PM
498sub fred {}
499$a = ${fred} ;
4438c4b7 500no warnings 'ambiguous' ;
0453d815 501$a = ${fred} ;
599cee73
PM
502EXPECT
503Ambiguous use of ${fred} resolved to $fred at - line 4.
504########
505# toke.c
4438c4b7 506use warnings 'syntax' ;
7fd134d9
JH
507$a = _123; print "$a\n"; #( 3 string)
508$a = 1_23; print "$a\n";
509$a = 12_3; print "$a\n";
510$a = 123_; print "$a\n"; # 6
511$a = _+123; print "$a\n"; # 7 string)
512$a = +_123; print "$a\n"; #( 8 string)
513$a = +1_23; print "$a\n";
514$a = +12_3; print "$a\n";
515$a = +123_; print "$a\n"; # 11
516$a = _-123; print "$a\n"; #(12 string)
517$a = -_123; print "$a\n"; #(13 string)
518$a = -1_23; print "$a\n";
519$a = -12_3; print "$a\n";
520$a = -123_; print "$a\n"; # 16
521$a = 123._456; print "$a\n"; # 17
522$a = 123.4_56; print "$a\n";
523$a = 123.45_6; print "$a\n";
524$a = 123.456_; print "$a\n"; # 20
525$a = +123._456; print "$a\n"; # 21
526$a = +123.4_56; print "$a\n";
527$a = +123.45_6; print "$a\n";
528$a = +123.456_; print "$a\n"; # 24
529$a = -123._456; print "$a\n"; # 25
530$a = -123.4_56; print "$a\n";
531$a = -123.45_6; print "$a\n";
532$a = -123.456_; print "$a\n"; # 28
2bea9a37
JH
533$a = 123.456E_12; printf("%.0f\n", $a); # 29
534$a = 123.456E1_2; printf("%.0f\n", $a);
535$a = 123.456E12_; printf("%.0f\n", $a); # 31
536$a = 123.456E_+12; printf("%.0f\n", $a); # 32
537$a = 123.456E+_12; printf("%.0f\n", $a); # 33
538$a = 123.456E+1_2; printf("%.0f\n", $a);
539$a = 123.456E+12_; printf("%.0f\n", $a); # 35
7fd134d9
JH
540$a = 123.456E_-12; print "$a\n"; # 36
541$a = 123.456E-_12; print "$a\n"; # 37
542$a = 123.456E-1_2; print "$a\n";
543$a = 123.456E-12_; print "$a\n"; # 39
b3b48e3e
JH
544$a = 1__23; print "$a\n"; # 40
545$a = 12.3__4; print "$a\n"; # 41
2bea9a37 546$a = 12.34e1__2; printf("%.0f\n", $a); # 42
4438c4b7 547no warnings 'syntax' ;
7fd134d9
JH
548$a = _123; print "$a\n";
549$a = 1_23; print "$a\n";
550$a = 12_3; print "$a\n";
551$a = 123_; print "$a\n";
552$a = _+123; print "$a\n";
553$a = +_123; print "$a\n";
554$a = +1_23; print "$a\n";
555$a = +12_3; print "$a\n";
556$a = +123_; print "$a\n";
557$a = _-123; print "$a\n";
558$a = -_123; print "$a\n";
559$a = -1_23; print "$a\n";
560$a = -12_3; print "$a\n";
561$a = -123_; print "$a\n";
562$a = 123._456; print "$a\n";
563$a = 123.4_56; print "$a\n";
564$a = 123.45_6; print "$a\n";
565$a = 123.456_; print "$a\n";
566$a = +123._456; print "$a\n";
567$a = +123.4_56; print "$a\n";
568$a = +123.45_6; print "$a\n";
569$a = +123.456_; print "$a\n";
570$a = -123._456; print "$a\n";
571$a = -123.4_56; print "$a\n";
572$a = -123.45_6; print "$a\n";
573$a = -123.456_; print "$a\n";
2bea9a37
JH
574$a = 123.456E_12; printf("%.0f\n", $a);
575$a = 123.456E1_2; printf("%.0f\n", $a);
576$a = 123.456E12_; printf("%.0f\n", $a);
577$a = 123.456E_+12; printf("%.0f\n", $a);
578$a = 123.456E+_12; printf("%.0f\n", $a);
579$a = 123.456E+1_2; printf("%.0f\n", $a);
580$a = 123.456E+12_; printf("%.0f\n", $a);
7fd134d9
JH
581$a = 123.456E_-12; print "$a\n";
582$a = 123.456E-_12; print "$a\n";
583$a = 123.456E-1_2; print "$a\n";
584$a = 123.456E-12_; print "$a\n";
b3b48e3e
JH
585$a = 1__23; print "$a\n";
586$a = 12.3__4; print "$a\n";
2bea9a37 587$a = 12.34e1__2; printf("%.0f\n", $a);
599cee73 588EXPECT
fbfa96bd 589OPTIONS regex
928753ea 590Misplaced _ in number at - line 6.
928753ea 591Misplaced _ in number at - line 11.
7fd134d9 592Misplaced _ in number at - line 16.
928753ea 593Misplaced _ in number at - line 17.
7fd134d9 594Misplaced _ in number at - line 20.
928753ea 595Misplaced _ in number at - line 21.
7fd134d9
JH
596Misplaced _ in number at - line 24.
597Misplaced _ in number at - line 25.
598Misplaced _ in number at - line 28.
599Misplaced _ in number at - line 29.
600Misplaced _ in number at - line 31.
601Misplaced _ in number at - line 32.
602Misplaced _ in number at - line 33.
603Misplaced _ in number at - line 35.
604Misplaced _ in number at - line 36.
605Misplaced _ in number at - line 37.
606Misplaced _ in number at - line 39.
b3b48e3e
JH
607Misplaced _ in number at - line 40.
608Misplaced _ in number at - line 41.
609Misplaced _ in number at - line 42.
928753ea
JH
610_123
611123
928753ea 612123
7fd134d9
JH
613123
614123
615_123
616123
617123
618123
619-123
620-_123
621-123
622-123
623-123
624123.456
625123.456
626123.456
627123.456
628123.456
629123.456
630123.456
631123.456
632-123.456
633-123.456
634-123.456
635-123.456
636123456000000000
637123456000000000
638123456000000000
639123456000000000
640123456000000000
641123456000000000
642123456000000000
fbfa96bd
NIS
6431.23456e-0?10
6441.23456e-0?10
6451.23456e-0?10
6461.23456e-0?10
b3b48e3e
JH
647123
64812.34
64912340000000000
7fd134d9
JH
650_123
651123
652123
653123
654123
655_123
656123
657123
658123
659-123
660-_123
661-123
662-123
663-123
664123.456
665123.456
666123.456
667123.456
668123.456
928753ea
JH
669123.456
670123.456
928753ea 671123.456
7fd134d9
JH
672-123.456
673-123.456
674-123.456
675-123.456
676123456000000000
677123456000000000
678123456000000000
679123456000000000
680123456000000000
681123456000000000
682123456000000000
fbfa96bd
NIS
6831.23456e-0?10
6841.23456e-0?10
6851.23456e-0?10
6861.23456e-0?10
b3b48e3e
JH
687123
68812.34
68912340000000000
599cee73
PM
690########
691# toke.c
e476b1b5 692use warnings 'bareword' ;
60e6418e 693#line 25 "bar"
599cee73 694$a = FRED:: ;
e476b1b5 695no warnings 'bareword' ;
0453d815
PM
696#line 25 "bar"
697$a = FRED:: ;
599cee73 698EXPECT
60e6418e 699Bareword "FRED::" refers to nonexistent package at bar line 25.
979a1401
BF
700########
701# toke.c
702use utf8;
703use open qw( :utf8 :std );
704use warnings 'bareword' ;
705#line 25 "bar"
706$a = FRÈD:: ;
707no warnings 'bareword' ;
708#line 25 "bar"
709$a = FRÈD:: ;
710EXPECT
711Bareword "FRÈD::" refers to nonexistent package at bar line 25.
712########
713# toke.c
714use utf8;
715use open qw( :utf8 :std );
716use warnings 'bareword' ;
717#line 25 "bar"
718$a = ϞϞϞ:: ;
719no warnings 'bareword' ;
720#line 25 "bar"
721$a = ϞϞϞ:: ;
722EXPECT
723Bareword "ϞϞϞ::" refers to nonexistent package at bar line 25.
599cee73
PM
724########
725# toke.c
4438c4b7 726use warnings 'ambiguous' ;
599cee73 727sub time {}
0453d815 728my $a = time() ;
4438c4b7 729no warnings 'ambiguous' ;
0453d815 730my $b = time() ;
599cee73
PM
731EXPECT
732Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
733########
734# toke.c
26d16222 735use warnings ;
0453d815 736eval <<'EOE';
df0deb90
GS
737# line 30 "foo"
738warn "yelp";
0453d815 739{
0453d815
PM
740 $_ = " \x{123} " ;
741}
742EOE
743EXPECT
df0deb90 744yelp at foo line 30.
0453d815
PM
745########
746# toke.c
0453d815 747my $a = rand + 4 ;
fbdd83da
DIM
748$a = rand *^H ;
749$a = rand $^H ;
0453d815 750EXPECT
2d5ccbba 751Warning: Use of "rand" without parentheses is ambiguous at - line 2.
0453d815
PM
752########
753# toke.c
754$^W = 0 ;
755my $a = rand + 4 ;
756{
4438c4b7 757 no warnings 'ambiguous' ;
0453d815 758 $a = rand + 4 ;
4438c4b7 759 use warnings 'ambiguous' ;
0453d815
PM
760 $a = rand + 4 ;
761}
762$a = rand + 4 ;
763EXPECT
2d5ccbba
IT
764Warning: Use of "rand" without parentheses is ambiguous at - line 3.
765Warning: Use of "rand" without parentheses is ambiguous at - line 8.
766Warning: Use of "rand" without parentheses is ambiguous at - line 10.
0453d815 767########
e19a021b
FC
768# [perl #97110]
769sub myrand(;$) { }
b5fb7ce3 770sub whatever($) { }
e19a021b 771my $a = myrand + 4 ;
b5fb7ce3 772my $b = whatever + 4 ;
e19a021b 773EXPECT
b5fb7ce3 774Warning: Use of "myrand" without parentheses is ambiguous at - line 4.
e19a021b 775########
0453d815 776# toke.c
e8ae98db
RGS
777use warnings "ambiguous";
778print for keys %+; # should not warn
779EXPECT
780########
781# toke.c
0453d815
PM
782sub fred {};
783-fred ;
898c3bca
FC
784sub hank : lvalue {$_}
785--hank; # This should *not* warn [perl #77240]
0453d815
PM
786EXPECT
787Ambiguous use of -fred resolved as -&fred() at - line 3.
788########
789# toke.c
790$^W = 0 ;
791sub fred {} ;
792-fred ;
793{
4438c4b7 794 no warnings 'ambiguous' ;
0453d815 795 -fred ;
4438c4b7 796 use warnings 'ambiguous' ;
0453d815
PM
797 -fred ;
798}
799-fred ;
800EXPECT
801Ambiguous use of -fred resolved as -&fred() at - line 4.
802Ambiguous use of -fred resolved as -&fred() at - line 9.
803Ambiguous use of -fred resolved as -&fred() at - line 11.
804########
805# toke.c
43b5ab4c
BF
806use utf8;
807use open qw( :utf8 :std );
808sub frèd {};
809-frèd ;
810EXPECT
811Ambiguous use of -frèd resolved as -&frèd() at - line 5.
812########
813# toke.c
814$^W = 0 ;
815use utf8;
816use open qw( :utf8 :std );
817sub frèd {} ;
818-frèd ;
819{
820 no warnings 'ambiguous' ;
821 -frèd ;
822 use warnings 'ambiguous' ;
823 -frèd ;
824}
825-frèd ;
826EXPECT
827Ambiguous use of -frèd resolved as -&frèd() at - line 6.
828Ambiguous use of -frèd resolved as -&frèd() at - line 11.
829Ambiguous use of -frèd resolved as -&frèd() at - line 13.
830########
831# toke.c
832use utf8;
833use open qw( :utf8 :std );
834sub ᒍᒘᒊ {};
835-ᒍᒘᒊ ;
836EXPECT
837Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 5.
838########
839# toke.c
840$^W = 0 ;
841use utf8;
842use open qw( :utf8 :std );
843sub ᒍᒘᒊ {} ;
844-ᒍᒘᒊ ;
845{
846 no warnings 'ambiguous' ;
847 -ᒍᒘᒊ ;
848 use warnings 'ambiguous' ;
849 -ᒍᒘᒊ ;
850}
851-ᒍᒘᒊ ;
852EXPECT
853Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 6.
854Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 11.
855Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 13.
856########
857# toke.c
0453d815 858open FOO || time;
240d1b6f 859open local *FOO; # should be ok
0453d815
PM
860EXPECT
861Precedence problem: open FOO should be open(FOO) at - line 2.
862########
71aa9713
BF
863# toke.c
864use utf8;
865use open qw( :utf8 :std );
866open FÒÒ || time;
867EXPECT
868Precedence problem: open FÒÒ should be open(FÒÒ) at - line 4.
869########
870# toke.c
871use utf8;
872use open qw( :utf8 :std );
873open ᒍOO || time;
874EXPECT
875Precedence problem: open ᒍOO should be open(ᒍOO) at - line 4.
876########
66fbe8fb
HS
877# toke.c (and [perl #16184])
878open FOO => "<&0"; close FOO;
879EXPECT
880########
0453d815
PM
881# toke.c
882$^W = 0 ;
883open FOO || time;
884{
e476b1b5 885 no warnings 'precedence' ;
0453d815 886 open FOO || time;
e476b1b5 887 use warnings 'precedence' ;
0453d815
PM
888 open FOO || time;
889}
890open FOO || time;
db3abe52 891open Foo::BAR; # this should not warn
0453d815
PM
892EXPECT
893Precedence problem: open FOO should be open(FOO) at - line 3.
894Precedence problem: open FOO should be open(FOO) at - line 8.
895Precedence problem: open FOO should be open(FOO) at - line 10.
896########
897# toke.c
898$^W = 0 ;
71aa9713
BF
899use utf8;
900use open qw( :utf8 :std );
901open FÒÒ || time;
902{
903 no warnings 'precedence' ;
904 open FÒÒ || time;
905 use warnings 'precedence' ;
906 open FÒÒ || time;
907}
908open FÒÒ || time;
909EXPECT
910Precedence problem: open FÒÒ should be open(FÒÒ) at - line 5.
911Precedence problem: open FÒÒ should be open(FÒÒ) at - line 10.
912Precedence problem: open FÒÒ should be open(FÒÒ) at - line 12.
913########
914# toke.c
915use utf8;
916use open qw( :utf8 :std );
917$^W = 0 ;
918open ᒍÒÒ || time;
919{
920 no warnings 'precedence' ;
921 open ᒍÒÒ || time;
922 use warnings 'precedence' ;
923 open ᒍÒÒ || time;
924}
925open ᒍÒÒ || time;
926EXPECT
927Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 5.
928Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 10.
929Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 12.
930########
931# toke.c
932$^W = 0 ;
0453d815
PM
933*foo *foo ;
934{
4438c4b7 935 no warnings 'ambiguous' ;
0453d815 936 *foo *foo ;
4438c4b7 937 use warnings 'ambiguous' ;
0453d815
PM
938 *foo *foo ;
939}
940*foo *foo ;
9700e2d3
FC
941# These should not warn [perl #117535]:
942foo**foo ;
943no warnings 'deprecated';
944sort $*foo ;
945sort $ *foo ;
0453d815
PM
946EXPECT
947Operator or semicolon missing before *foo at - line 3.
948Ambiguous use of * resolved as operator * at - line 3.
949Operator or semicolon missing before *foo at - line 8.
950Ambiguous use of * resolved as operator * at - line 8.
951Operator or semicolon missing before *foo at - line 10.
952Ambiguous use of * resolved as operator * at - line 10.
767a6a26
PM
953########
954# toke.c
9700e2d3
FC
955$^W = 0 ;
956%foo %foo ;
957{
958 no warnings 'ambiguous' ;
959 %foo %foo ;
960 use warnings 'ambiguous' ;
961 %foo %foo ;
962}
963%foo %foo ;
964# This should not produce ambiguity warnings [perl #117535]:
965sort $%foo ;
966sort $ %foo ;
967EXPECT
968Operator or semicolon missing before %foo at - line 3.
969Ambiguous use of % resolved as operator % at - line 3.
970Operator or semicolon missing before %foo at - line 8.
971Ambiguous use of % resolved as operator % at - line 8.
972Operator or semicolon missing before %foo at - line 10.
973Ambiguous use of % resolved as operator % at - line 10.
974Bareword found where operator expected at - line 12, near "$%foo"
975 (Missing operator before foo?)
976Bareword found where operator expected at - line 13, near "$ %foo"
977 (Missing operator before foo?)
978Illegal modulus zero at - line 3.
979########
980# toke.c
981$^W = 0 ;
982&foo &foo ;
983{
984 no warnings 'ambiguous' ;
985 &foo &foo ;
986 use warnings 'ambiguous' ;
987 &foo &foo ;
988}
989&foo &foo ;
990# These should not warn produce ambiguity warnings [perl #76910]:
991foo&&foo ;
992sort $&foo ;
993sort $ &foo ;
994EXPECT
995Operator or semicolon missing before &foo at - line 3.
996Ambiguous use of & resolved as operator & at - line 3.
997Operator or semicolon missing before &foo at - line 8.
998Ambiguous use of & resolved as operator & at - line 8.
999Operator or semicolon missing before &foo at - line 10.
1000Ambiguous use of & resolved as operator & at - line 10.
1001Bareword found where operator expected at - line 13, near "$&foo"
1002 (Missing operator before foo?)
1003Bareword found where operator expected at - line 14, near "$ &foo"
1004 (Missing operator before foo?)
1005Undefined subroutine &main::foo called at - line 3.
1006########
1007# toke.c
02571fe8
BF
1008use utf8;
1009use open qw( :utf8 :std );
1010$^W = 0 ;
1011*foo *foo ;
1012{
1013 no warnings 'ambiguous' ;
1014 *foo *foo ;
1015 use warnings 'ambiguous' ;
1016 *foo *foo ;
1017}
1018*foo *foo ;
1019EXPECT
1020Operator or semicolon missing before *foo at - line 5.
1021Ambiguous use of * resolved as operator * at - line 5.
1022Operator or semicolon missing before *foo at - line 10.
1023Ambiguous use of * resolved as operator * at - line 10.
1024Operator or semicolon missing before *foo at - line 12.
1025Ambiguous use of * resolved as operator * at - line 12.
1026########
1027# toke.c
e476b1b5 1028use warnings 'misc' ;
767a6a26 1029my $a = "\m" ;
e476b1b5 1030no warnings 'misc' ;
767a6a26
PM
1031$a = "\m" ;
1032EXPECT
1033Unrecognized escape \m passed through at - line 3.
1034########
1035# toke.c
52ed07f6
BF
1036use warnings 'misc' ;
1037my $a = "abcd\E" ;
1038no warnings 'misc' ;
1039$a = "abcd\E" ;
1040EXPECT
820438b1 1041Useless use of \E at - line 3.
52ed07f6
BF
1042########
1043# toke.c
767a6a26
PM
1044use warnings 'portable' ;
1045my $a = 0b011111111111111111111111111111110 ;
1046 $a = 0b011111111111111111111111111111111 ;
1047 $a = 0b111111111111111111111111111111111 ;
1048 $a = 0x0fffffffe ;
1049 $a = 0x0ffffffff ;
1050 $a = 0x1ffffffff ;
1051 $a = 0037777777776 ;
1052 $a = 0037777777777 ;
1053 $a = 0047777777777 ;
1054no warnings 'portable' ;
1055 $a = 0b011111111111111111111111111111110 ;
1056 $a = 0b011111111111111111111111111111111 ;
1057 $a = 0b111111111111111111111111111111111 ;
1058 $a = 0x0fffffffe ;
1059 $a = 0x0ffffffff ;
1060 $a = 0x1ffffffff ;
1061 $a = 0037777777776 ;
1062 $a = 0037777777777 ;
1063 $a = 0047777777777 ;
1064EXPECT
1065Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
1066Hexadecimal number > 0xffffffff non-portable at - line 8.
1067Octal number > 037777777777 non-portable at - line 11.
1068########
1069# toke.c
1070use warnings 'overflow' ;
1071my $a = 0b011111111111111111111111111111110 ;
1072 $a = 0b011111111111111111111111111111111 ;
15041a67 1073 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
1074 $a = 0x0fffffffe ;
1075 $a = 0x0ffffffff ;
15041a67 1076 $a = 0x10000000000000000 ;
767a6a26
PM
1077 $a = 0037777777776 ;
1078 $a = 0037777777777 ;
15041a67 1079 $a = 002000000000000000000000;
767a6a26
PM
1080no warnings 'overflow' ;
1081 $a = 0b011111111111111111111111111111110 ;
1082 $a = 0b011111111111111111111111111111111 ;
15041a67 1083 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
1084 $a = 0x0fffffffe ;
1085 $a = 0x0ffffffff ;
15041a67 1086 $a = 0x10000000000000000 ;
767a6a26
PM
1087 $a = 0037777777776 ;
1088 $a = 0037777777777 ;
15041a67 1089 $a = 002000000000000000000000;
767a6a26
PM
1090EXPECT
1091Integer overflow in binary number at - line 5.
1092Integer overflow in hexadecimal number at - line 8.
1093Integer overflow in octal number at - line 11.
8593bda5
GS
1094########
1095# toke.c
ac206dc8
RGS
1096BEGIN { $^C = 1; }
1097use warnings 'misc';
1098dump;
1099CORE::dump;
1100EXPECT
1101dump() better written as CORE::dump() at - line 4.
1102- syntax OK
1103########
1104# toke.c
1105use warnings 'misc';
1106use subs qw/dump/;
93f09d7b 1107sub dump { print "no warning for overridden dump\n"; }
ac206dc8
RGS
1108dump;
1109EXPECT
93f09d7b 1110no warning for overridden dump
ac206dc8
RGS
1111########
1112# toke.c
8593bda5
GS
1113use warnings 'ambiguous';
1114"@mjd_previously_unused_array";
1115no warnings 'ambiguous';
29fb1d0e 1116"@mjd_previously_unused_array2";
8593bda5
GS
1117EXPECT
1118Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.
707afd92
MS
1119########
1120# toke.c
29fb1d0e
BF
1121use utf8;
1122use open qw( :utf8 :std );
1123use warnings 'ambiguous';
1124"@mjd_previously_unused_àrray";
1125no warnings 'ambiguous';
1126"@mjd_previously_unused_àrray2";
1127EXPECT
1128Possible unintended interpolation of @mjd_previously_unused_àrray in string at - line 5.
1129########
1130# toke.c
1131use utf8;
1132use open qw( :utf8 :std );
1133use warnings 'ambiguous';
1134"@mjd_previously_unused_ぁrrぁy";
1135no warnings 'ambiguous';
1136"@mjd_previously_unused_ぁrrぁy2";
1137EXPECT
1138Possible unintended interpolation of @mjd_previously_unused_ぁrrぁy in string at - line 5.
1139########
1140# toke.c
d8c55666 1141# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
1142use warnings 'regexp';
1143"foo" =~ /foo/c;
64e578a2 1144"foo" =~ /foo/cg;
4ac733c9
MJD
1145no warnings 'regexp';
1146"foo" =~ /foo/c;
64e578a2 1147"foo" =~ /foo/cg;
4ac733c9
MJD
1148EXPECT
1149Use of /c modifier is meaningless without /g at - line 4.
1150########
1151# toke.c
d8c55666 1152# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
1153use warnings 'regexp';
1154$_ = "ab" ;
1155s/ab/ab/c;
64e578a2 1156s/ab/ab/cg;
4ac733c9
MJD
1157no warnings 'regexp';
1158s/ab/ab/c;
64e578a2 1159s/ab/ab/cg;
4ac733c9 1160EXPECT
64e578a2
MJD
1161Use of /c modifier is meaningless in s/// at - line 5.
1162Use of /c modifier is meaningless in s/// at - line 6.
d8c55666
MJD
1163########
1164-wa
1165# toke.c
1166# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
1167print "@F\n";
1168EXPECT
1169
1170########
1171-w
1172# toke.c
1173# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
1174print "@F\n";
1175EXPECT
1176Possible unintended interpolation of @F in string at - line 4.
1177Name "main::F" used only once: possible typo at - line 4.
1178########
1179-wa
1180# toke.c
1181# 20020414 mjd-perl-patch+@plover.com
1182EXPECT
1183
2710853f
MJD
1184########
1185# toke.c
1186# 20020414 mjd-perl-patch+@plover.com
1187# In 5.7.3, this emitted "Possible unintended interpolation" warnings
1188use warnings 'ambiguous';
1189$s = "(@-)(@+)";
1190EXPECT
1191
56da5a46
RGS
1192########
1193# toke.c
1194# mandatory warning
1195eval q/if ($a) { } elseif ($b) { }/;
1196no warnings "syntax";
1197eval q/if ($a) { } elseif ($b) { }/;
1198EXPECT
1199elseif should be elsif at (eval 1) line 1.
1200########
1201# toke.c
1202# mandatory warning
1203eval q/5 6/;
1204no warnings "syntax";
1205eval q/5 6/;
1206EXPECT
1207Number found where operator expected at (eval 1) line 1, near "5 6"
1208 (Missing operator before 6?)
984200d0
YST
1209########
1210# toke.c
7fc874e8 1211use warnings "syntax"; no warnings "deprecated";
984200d0
YST
1212$_ = $a = 1;
1213$a !=~ /1/;
1214$a !=~ m#1#;
1215$a !=~/1/;
1216$a !=~ ?/?;
decca21c
YST
1217$a !=~ y/1//;
1218$a !=~ tr/1//;
1219$a !=~ s/1//;
984200d0
YST
1220$a != ~/1/;
1221no warnings "syntax";
1222$a !=~ /1/;
1223$a !=~ m#1#;
1224$a !=~/1/;
1225$a !=~ ?/?;
decca21c
YST
1226$a !=~ y/1//;
1227$a !=~ tr/1//;
1228$a !=~ s/1//;
984200d0
YST
1229EXPECT
1230!=~ should be !~ at - line 4.
1231!=~ should be !~ at - line 5.
1232!=~ should be !~ at - line 6.
1233!=~ should be !~ at - line 7.
decca21c
YST
1234!=~ should be !~ at - line 8.
1235!=~ should be !~ at - line 9.
1236!=~ should be !~ at - line 10.
1108974d
RGS
1237########
1238# toke.c
1239our $foo :unique;
8e5dadda
NC
1240sub pam :locked;
1241sub glipp :locked {
1242}
1243sub whack_eth ($) : locked {
1244}
d1d15184 1245no warnings 'deprecated';
1108974d 1246our $bar :unique;
8e5dadda
NC
1247sub zapeth :locked;
1248sub ker_plop :locked {
1249}
1250sub swa_a_p ($) : locked {
1251}
1108974d 1252EXPECT
d1d15184
NC
1253Use of :unique is deprecated at - line 2.
1254Use of :locked is deprecated at - line 3.
1255Use of :locked is deprecated at - line 4.
1256Use of :locked is deprecated at - line 6.
9e8d7757
RB
1257########
1258# toke.c
e7d0b801 1259use warnings "syntax"; use feature 'lexical_subs';
9e8d7757
RB
1260sub proto_after_array(@$);
1261sub proto_after_arref(\@$);
1262sub proto_after_arref2(\[@$]);
1263sub proto_after_arref3(\[@$]_);
1264sub proto_after_hash(%$);
1265sub proto_after_hashref(\%$);
1266sub proto_after_hashref2(\[%$]);
1267sub underscore_last_pos($_);
1268sub underscore2($_;$);
1269sub underscore_fail($_$);
1270sub underscore_after_at(@_);
689aac7b
FC
1271our sub hour (@$);
1272my sub migh (@$);
e7d0b801 1273use feature 'state';
689aac7b
FC
1274state sub estate (@$);
1275package other;
1276sub hour (@$);
1277sub migh (@$);
1278sub estate (@$);
9e8d7757
RB
1279no warnings "syntax";
1280sub proto_after_array(@$);
1281sub proto_after_hash(%$);
1282sub underscore_fail($_$);
1283EXPECT
1284Prototype after '@' for main::proto_after_array : @$ at - line 3.
1285Prototype after '%' for main::proto_after_hash : %$ at - line 7.
aef2a98a 1286Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12.
9e8d7757 1287Prototype after '@' for main::underscore_after_at : @_ at - line 13.
64fbf0dd 1288The lexical_subs feature is experimental at - line 14.
689aac7b 1289Prototype after '@' for hour : @$ at - line 14.
64fbf0dd 1290The lexical_subs feature is experimental at - line 15.
689aac7b 1291Prototype after '@' for migh : @$ at - line 15.
64fbf0dd 1292The lexical_subs feature is experimental at - line 17.
689aac7b
FC
1293Prototype after '@' for estate : @$ at - line 17.
1294Prototype after '@' for hour : @$ at - line 19.
1295Prototype after '@' for migh : @$ at - line 20.
1296Prototype after '@' for estate : @$ at - line 21.
77772344
B
1297########
1298# toke.c
1299use warnings "ambiguous";
1300"foo\nn" =~ /^foo$\n/;
1301"foo\nn" =~ /^foo${\}n/;
1302my $foo = qr/^foo$\n/;
1303my $bar = qr/^foo${\}n/;
1304no warnings "ambiguous";
1305"foo\nn" =~ /^foo$\n/;
1306"foo\nn" =~ /^foo${\}n/;
1307my $foo = qr/^foo$\n/;
1308my $bar = qr/^foo${\}n/;
1309EXPECT
1310Possible unintended interpolation of $\ in regex at - line 3.
1311Possible unintended interpolation of $\ in regex at - line 5.
d83f38d8
NC
1312########
1313# toke.c
f0a2b745
KW
1314use warnings 'syntax' ;
1315my $a = "\o";
1316my $a = "\o{";
1317my $a = "\o{}";
1318no warnings 'syntax' ;
1319my $a = "\o";
1320my $a = "\o{";
1321my $a = "\o{}";
1322EXPECT
1323Missing braces on \o{} at - line 3, within string
1324Missing right brace on \o{ at - line 4, within string
1325Number with no digits at - line 5, within string
1326BEGIN not safe after errors--compilation aborted at - line 6.
1327########
1328# toke.c
1329use warnings 'digit' ;
1330my $a = "\o{1238456}";
1331no warnings 'digit' ;
1332my $a = "\o{1238456}";
1333EXPECT
1334Non-octal character '8'. Resolved as "\o{123}" at - line 3.
725a61d7
Z
1335########
1336# toke.c
1337use warnings;
1338my $a = "foo";
1339print $a =~ ?f? ? "yes\n" : "no\n" foreach 0..2;
1340EXPECT
1341Use of ?PATTERN? without explicit operator is deprecated at - line 4.
1342yes
1343no
1344no
17a3df4c
KW
1345########
1346# toke.c
1347use warnings;
1348my $a = "\c{ack}";
1349$a = "\c,";
1350$a = "\c`";
1351no warnings 'syntax';
1352$a = "\c{ack}";
1353$a = "\c,";
1354$a = "\c`";
1355no warnings 'deprecated';
1356EXPECT
1357"\c{" is deprecated and is more clearly written as ";" at - line 3.
1358"\c," is more clearly written simply as "l" at - line 4.
1359"\c`" is more clearly written simply as "\ " at - line 5.
1360"\c{" is deprecated and is more clearly written as ";" at - line 7.
3955e1a9
KW
1361########
1362# toke.c
1363use warnings 'syntax' ;
1364my $a = qr/foo/du;
ff3f26d2 1365$a = qr/foo/lai;
3955e1a9 1366$a = qr/foo/lil;
ff3f26d2
KW
1367$a = qr/foo/aia;
1368$a = qr/foo/aaia;
3955e1a9
KW
1369no warnings 'syntax' ;
1370my $a = qr/foo/du;
1371EXPECT
1372Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= "
1373Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= "
1374Regexp modifier "/l" may not appear twice at - line 5, near "= "
ff3f26d2
KW
1375Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= "
1376BEGIN not safe after errors--compilation aborted at - line 8.
ba05d9aa
FC
1377########
1378# toke.c
1379# [perl #4362]
1380eval "print q\xabfoo";
1381print "ok\n" if
1382 $@ =~ /Can't find string terminator "\xab" anywhere before EOF/;
1383EXPECT
1384ok
5c66c3dd
BF
1385########
1386# toke.c
1387use utf8;
1388use open qw( :utf8 :std );
1389use warnings 'ambiguous' ;
1390sub frèd {}
1391$a = ${frèd} ;
1392no warnings 'ambiguous' ;
1393$a = ${frèd} ;
1394EXPECT
1395Ambiguous use of ${frèd} resolved to $frèd at - line 6.
1396########
1397# toke.c
1398use utf8;
1399use open qw( :utf8 :std );
1400use warnings 'ambiguous' ;
1401sub f렏 {}
1402$a = ${f렏} ;
1403no warnings 'ambiguous' ;
1404$a = ${f렏} ;
1405EXPECT
1406Ambiguous use of ${f렏} resolved to $f렏 at - line 6.
3773592b
BF
1407########
1408# toke.c
1409use utf8;
1410use open qw( :utf8 :std );
1411use warnings;
1412CORE::렏;
1413EXPECT
1414CORE::렏 is not a keyword at - line 5.
5dc13276
MH
1415########
1416# toke.c
1417# [perl #16249]
1418print '';
1419eval this_method_is_fake ();
1420EXPECT
1421Undefined subroutine &main::this_method_is_fake called at - line 4.
a71a1afb
FC
1422########
1423# toke.c
1424# [perl #107002] Erroneous ambiguity warnings
1425sub { # do not actually call require
1426 require a::b . 1; # These used to produce erroneous
1427 require a::b + 1; # ambiguity warnings.
1428}
1429EXPECT
4d68ffa0
KW
1430########
1431# toke.c
70502ce0 1432# [perl #113094], [perl #119101]
4d68ffa0
KW
1433print "aa" =~ m{^a\{1,2\}$}, "\n";
1434print "aa" =~ m{^a\x\{61\}$}, "\n";
70502ce0
KW
1435print "a\\x{6F}" =~ m{^a\\x\{6F\}$}, "\n";
1436print "a\\o" =~ m{^a\\\x\{6F\}$}, "\n";
1437print "a\\\\x{6F}" =~ m{^a\\\\x\{6F\}$}, "\n";
1438print "a\\\\o" =~ m{^a\\\\\x\{6F\}$}, "\n";
4d68ffa0
KW
1439print "aa" =~ m{^a{1,2}$}, "\n";
1440print "aq" =~ m[^a\[a-z\]$], "\n";
1441print "aq" =~ m(^a\(q\)$), "\n";
1442no warnings 'deprecated';
1443print "aa" =~ m{^a\{1,2\}$}, "\n";
1444print "aa" =~ m{^a\x\{61\}$}, "\n";
70502ce0
KW
1445print "a\\x{6F}" =~ m{^a\\x\{6F\}$}, "\n";
1446print "a\\o" =~ m{^a\\\x\{6f\}$}, "\n";
4d68ffa0
KW
1447print "aq" =~ m[^a\[a-z\]$], "\n";
1448print "aq" =~ m(^a\(q\)$), "\n";
1449EXPECT
1450Useless use of '\'; doesn't escape metacharacter '{' at - line 3.
1451Useless use of '\'; doesn't escape metacharacter '{' at - line 4.
70502ce0
KW
1452Useless use of '\'; doesn't escape metacharacter '{' at - line 6.
1453Useless use of '\'; doesn't escape metacharacter '{' at - line 8.
1454Useless use of '\'; doesn't escape metacharacter '[' at - line 10.
1455Useless use of '\'; doesn't escape metacharacter '(' at - line 11.
14561
14571
14581
14591
4d68ffa0
KW
14601
14611
14621
14631
1464q
14651
14661
14671
70502ce0
KW
14681
14691
4d68ffa0 1470q
b29f65fc
BF
1471########
1472# toke.c
1473#[perl #119123] disallow literal control character variables
1474eval "\$\cQ = 25";
1475eval "\${ \cX } = 24";
1476*{
1477 Foo
1478}; # shouldn't warn on {\n, even though \n is a control character
1479EXPECT
1480Use of literal control characters in variable names is deprecated at (eval 1) line 1.
1481Use of literal control characters in variable names is deprecated at (eval 2) line 1.