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