This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
spurious "Use of "-x" without parentheses" mesg
[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;
4438c4b7 307no warnings 'syntax' ;
0453d815
PM
308$_ = "ab" ;
309s/(ab)/\1/e;
599cee73
PM
310EXPECT
311Can't use \1 to mean $1 in expression at - line 4.
312########
313# toke.c
4438c4b7 314use warnings 'reserved' ;
599cee73 315$a = abc;
1c3923b3
GS
316$a = { def
317
318=> 1 };
4438c4b7 319no warnings 'reserved' ;
0453d815 320$a = abc;
599cee73
PM
321EXPECT
322Unquoted string "abc" may clash with future reserved word at - line 3.
323########
324# toke.c
e476b1b5 325use warnings 'qw' ;
599cee73 326@a = qw(a, b, c) ;
e476b1b5 327no warnings 'qw' ;
0453d815 328@a = qw(a, b, c) ;
599cee73
PM
329EXPECT
330Possible attempt to separate words with commas at - line 3.
331########
332# toke.c
e476b1b5 333use warnings 'qw' ;
7e03b518 334@a = qw(a b c # #) ;
e476b1b5 335no warnings 'qw' ;
7e03b518 336@a = qw(a b c # #) ;
599cee73
PM
337EXPECT
338Possible attempt to put comments in qw() list at - line 3.
339########
340# toke.c
7e03b518
EB
341use warnings 'qw' ;
342@a = qw(a, b, c # #) ;
343no warnings 'qw' ;
344@a = qw(a, b, c # #) ;
345EXPECT
346Possible attempt to separate words with commas at - line 3.
347Possible attempt to put comments in qw() list at - line 3.
348########
349# toke.c
4438c4b7 350use warnings 'syntax' ;
b1439985
RGS
351print ("");
352print ("") and $x = 1;
353print ("") or die;
354print ("") // die;
355print (1+2) * 3 if 0; # only this one should warn
356print (1+2) if 0;
599cee73 357EXPECT
b1439985 358print (...) interpreted as function at - line 7.
599cee73
PM
359########
360# toke.c
4438c4b7 361no warnings 'syntax' ;
0453d815
PM
362print ("")
363EXPECT
364
365########
366# toke.c
4438c4b7 367use warnings 'syntax' ;
b1439985
RGS
368printf ("");
369printf ("") . '';
599cee73 370EXPECT
b1439985 371printf (...) interpreted as function at - line 4.
599cee73
PM
372########
373# toke.c
4438c4b7 374no warnings 'syntax' ;
0453d815
PM
375printf ("")
376EXPECT
377
378########
379# toke.c
4438c4b7 380use warnings 'syntax' ;
b1439985
RGS
381sort ("");
382sort ("") . '';
599cee73 383EXPECT
b1439985 384sort (...) interpreted as function at - line 4.
599cee73
PM
385########
386# toke.c
4438c4b7 387no warnings 'syntax' ;
0453d815
PM
388sort ("")
389EXPECT
390
391########
392# toke.c
4438c4b7 393use warnings 'ambiguous' ;
599cee73 394$a = ${time[2]};
4438c4b7 395no warnings 'ambiguous' ;
0453d815 396$a = ${time[2]};
599cee73
PM
397EXPECT
398Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
399########
400# toke.c
4438c4b7 401use warnings 'ambiguous' ;
599cee73
PM
402$a = ${time{2}};
403EXPECT
404Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
405########
406# toke.c
a49b10d0
BF
407use warnings 'ambiguous' ;
408$a = ${
409
410 time
411 {2}
412};
413warn "after";
414EXPECT
415Ambiguous use of ${time{...}} resolved to $time{...} at - line 5.
416after at - line 8.
417########
418# toke.c
419use warnings 'ambiguous' ;
420$a = ${
421
422time[2]
423
424};
425$a = ${
426
427time
428 [2]
429
430};
431warn "after";
432EXPECT
433Ambiguous use of ${time[...]} resolved to $time[...] at - line 5.
434Ambiguous use of ${time[...]} resolved to $time[...] at - line 10.
435after at - line 14.
436########
437# toke.c
4438c4b7 438no warnings 'ambiguous' ;
0453d815
PM
439$a = ${time{2}};
440EXPECT
441
442########
443# toke.c
4438c4b7 444use warnings 'ambiguous' ;
599cee73 445$a = ${time} ;
27ffb73a
NC
446$a = @{time} ;
447$a = $#{time} ; # This one is special cased in toke.c
448$a = %{time} ;
449$a = *{time} ;
450$a = defined &{time} ; # To avoid calling &::time
4438c4b7 451no warnings 'ambiguous' ;
0453d815 452$a = ${time} ;
27ffb73a
NC
453$a = @{time} ;
454$a = $#{time} ; # This one is special cased in toke.c
455$a = %{time} ;
456$a = *{time} ;
457$a = defined &{time} ; # To avoid calling &::time
599cee73
PM
458EXPECT
459Ambiguous use of ${time} resolved to $time at - line 3.
27ffb73a
NC
460Ambiguous use of @{time} resolved to @time at - line 4.
461Ambiguous use of @{time} resolved to @time at - line 5.
462Ambiguous use of %{time} resolved to %time at - line 6.
463Ambiguous use of *{time} resolved to *time at - line 7.
464Ambiguous use of &{time} resolved to &time at - line 8.
599cee73
PM
465########
466# toke.c
4438c4b7 467use warnings 'ambiguous' ;
a49b10d0
BF
468$a = ${
469time
470} ;
471$a = @{
472time
473} ;
474$a = $#{
475time
476} ;
477$a = %{
478time
479} ;
480$a = *{
481time
482} ;
483$a = defined &{
484time
485
486
487} ;
488warn "last";
489EXPECT
490Ambiguous use of ${time} resolved to $time at - line 4.
491Ambiguous use of @{time} resolved to @time at - line 7.
492Ambiguous use of @{time} resolved to @time at - line 10.
493Ambiguous use of %{time} resolved to %time at - line 13.
494Ambiguous use of *{time} resolved to *time at - line 16.
495Ambiguous use of &{time} resolved to &time at - line 19.
496last at - line 23.
497########
498# toke.c
499use warnings 'ambiguous' ;
599cee73
PM
500sub fred {}
501$a = ${fred} ;
4438c4b7 502no warnings 'ambiguous' ;
0453d815 503$a = ${fred} ;
599cee73
PM
504EXPECT
505Ambiguous use of ${fred} resolved to $fred at - line 4.
506########
507# toke.c
4438c4b7 508use warnings 'syntax' ;
7fd134d9
JH
509$a = _123; print "$a\n"; #( 3 string)
510$a = 1_23; print "$a\n";
511$a = 12_3; print "$a\n";
512$a = 123_; print "$a\n"; # 6
513$a = _+123; print "$a\n"; # 7 string)
514$a = +_123; print "$a\n"; #( 8 string)
515$a = +1_23; print "$a\n";
516$a = +12_3; print "$a\n";
517$a = +123_; print "$a\n"; # 11
518$a = _-123; print "$a\n"; #(12 string)
519$a = -_123; print "$a\n"; #(13 string)
520$a = -1_23; print "$a\n";
521$a = -12_3; print "$a\n";
522$a = -123_; print "$a\n"; # 16
523$a = 123._456; print "$a\n"; # 17
524$a = 123.4_56; print "$a\n";
525$a = 123.45_6; print "$a\n";
526$a = 123.456_; print "$a\n"; # 20
527$a = +123._456; print "$a\n"; # 21
528$a = +123.4_56; print "$a\n";
529$a = +123.45_6; print "$a\n";
530$a = +123.456_; print "$a\n"; # 24
531$a = -123._456; print "$a\n"; # 25
532$a = -123.4_56; print "$a\n";
533$a = -123.45_6; print "$a\n";
534$a = -123.456_; print "$a\n"; # 28
2bea9a37
JH
535$a = 123.456E_12; printf("%.0f\n", $a); # 29
536$a = 123.456E1_2; printf("%.0f\n", $a);
537$a = 123.456E12_; printf("%.0f\n", $a); # 31
538$a = 123.456E_+12; printf("%.0f\n", $a); # 32
539$a = 123.456E+_12; printf("%.0f\n", $a); # 33
540$a = 123.456E+1_2; printf("%.0f\n", $a);
541$a = 123.456E+12_; printf("%.0f\n", $a); # 35
7fd134d9
JH
542$a = 123.456E_-12; print "$a\n"; # 36
543$a = 123.456E-_12; print "$a\n"; # 37
544$a = 123.456E-1_2; print "$a\n";
545$a = 123.456E-12_; print "$a\n"; # 39
b3b48e3e
JH
546$a = 1__23; print "$a\n"; # 40
547$a = 12.3__4; print "$a\n"; # 41
2bea9a37 548$a = 12.34e1__2; printf("%.0f\n", $a); # 42
4438c4b7 549no warnings 'syntax' ;
7fd134d9
JH
550$a = _123; print "$a\n";
551$a = 1_23; print "$a\n";
552$a = 12_3; print "$a\n";
553$a = 123_; print "$a\n";
554$a = _+123; print "$a\n";
555$a = +_123; print "$a\n";
556$a = +1_23; print "$a\n";
557$a = +12_3; print "$a\n";
558$a = +123_; print "$a\n";
559$a = _-123; print "$a\n";
560$a = -_123; print "$a\n";
561$a = -1_23; print "$a\n";
562$a = -12_3; print "$a\n";
563$a = -123_; print "$a\n";
564$a = 123._456; print "$a\n";
565$a = 123.4_56; print "$a\n";
566$a = 123.45_6; print "$a\n";
567$a = 123.456_; print "$a\n";
568$a = +123._456; print "$a\n";
569$a = +123.4_56; print "$a\n";
570$a = +123.45_6; print "$a\n";
571$a = +123.456_; print "$a\n";
572$a = -123._456; print "$a\n";
573$a = -123.4_56; print "$a\n";
574$a = -123.45_6; print "$a\n";
575$a = -123.456_; print "$a\n";
2bea9a37
JH
576$a = 123.456E_12; printf("%.0f\n", $a);
577$a = 123.456E1_2; printf("%.0f\n", $a);
578$a = 123.456E12_; printf("%.0f\n", $a);
579$a = 123.456E_+12; printf("%.0f\n", $a);
580$a = 123.456E+_12; printf("%.0f\n", $a);
581$a = 123.456E+1_2; printf("%.0f\n", $a);
582$a = 123.456E+12_; printf("%.0f\n", $a);
7fd134d9
JH
583$a = 123.456E_-12; print "$a\n";
584$a = 123.456E-_12; print "$a\n";
585$a = 123.456E-1_2; print "$a\n";
586$a = 123.456E-12_; print "$a\n";
b3b48e3e
JH
587$a = 1__23; print "$a\n";
588$a = 12.3__4; print "$a\n";
2bea9a37 589$a = 12.34e1__2; printf("%.0f\n", $a);
599cee73 590EXPECT
fbfa96bd 591OPTIONS regex
928753ea 592Misplaced _ in number at - line 6.
928753ea 593Misplaced _ in number at - line 11.
7fd134d9 594Misplaced _ in number at - line 16.
928753ea 595Misplaced _ in number at - line 17.
7fd134d9 596Misplaced _ in number at - line 20.
928753ea 597Misplaced _ in number at - line 21.
7fd134d9
JH
598Misplaced _ in number at - line 24.
599Misplaced _ in number at - line 25.
600Misplaced _ in number at - line 28.
601Misplaced _ in number at - line 29.
602Misplaced _ in number at - line 31.
603Misplaced _ in number at - line 32.
604Misplaced _ in number at - line 33.
605Misplaced _ in number at - line 35.
606Misplaced _ in number at - line 36.
607Misplaced _ in number at - line 37.
608Misplaced _ in number at - line 39.
b3b48e3e
JH
609Misplaced _ in number at - line 40.
610Misplaced _ in number at - line 41.
611Misplaced _ in number at - line 42.
928753ea
JH
612_123
613123
928753ea 614123
7fd134d9
JH
615123
616123
617_123
618123
619123
620123
621-123
622-_123
623-123
624-123
625-123
626123.456
627123.456
628123.456
629123.456
630123.456
631123.456
632123.456
633123.456
634-123.456
635-123.456
636-123.456
637-123.456
638123456000000000
639123456000000000
640123456000000000
641123456000000000
642123456000000000
643123456000000000
644123456000000000
fbfa96bd
NIS
6451.23456e-0?10
6461.23456e-0?10
6471.23456e-0?10
6481.23456e-0?10
b3b48e3e
JH
649123
65012.34
65112340000000000
7fd134d9
JH
652_123
653123
654123
655123
656123
657_123
658123
659123
660123
661-123
662-_123
663-123
664-123
665-123
666123.456
667123.456
668123.456
669123.456
670123.456
928753ea
JH
671123.456
672123.456
928753ea 673123.456
7fd134d9
JH
674-123.456
675-123.456
676-123.456
677-123.456
678123456000000000
679123456000000000
680123456000000000
681123456000000000
682123456000000000
683123456000000000
684123456000000000
fbfa96bd
NIS
6851.23456e-0?10
6861.23456e-0?10
6871.23456e-0?10
6881.23456e-0?10
b3b48e3e
JH
689123
69012.34
69112340000000000
599cee73
PM
692########
693# toke.c
e476b1b5 694use warnings 'bareword' ;
60e6418e 695#line 25 "bar"
599cee73 696$a = FRED:: ;
e476b1b5 697no warnings 'bareword' ;
0453d815
PM
698#line 25 "bar"
699$a = FRED:: ;
599cee73 700EXPECT
60e6418e 701Bareword "FRED::" refers to nonexistent package at bar line 25.
979a1401
BF
702########
703# toke.c
704use utf8;
705use open qw( :utf8 :std );
706use warnings 'bareword' ;
707#line 25 "bar"
708$a = FRÈD:: ;
709no warnings 'bareword' ;
710#line 25 "bar"
711$a = FRÈD:: ;
712EXPECT
713Bareword "FRÈD::" refers to nonexistent package at bar line 25.
714########
715# toke.c
716use utf8;
717use open qw( :utf8 :std );
718use warnings 'bareword' ;
719#line 25 "bar"
720$a = ϞϞϞ:: ;
721no warnings 'bareword' ;
722#line 25 "bar"
723$a = ϞϞϞ:: ;
724EXPECT
725Bareword "ϞϞϞ::" refers to nonexistent package at bar line 25.
599cee73
PM
726########
727# toke.c
4438c4b7 728use warnings 'ambiguous' ;
599cee73 729sub time {}
0453d815 730my $a = time() ;
4438c4b7 731no warnings 'ambiguous' ;
0453d815 732my $b = time() ;
599cee73
PM
733EXPECT
734Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
735########
736# toke.c
26d16222 737use warnings ;
0453d815 738eval <<'EOE';
df0deb90
GS
739# line 30 "foo"
740warn "yelp";
0453d815 741{
0453d815
PM
742 $_ = " \x{123} " ;
743}
744EOE
745EXPECT
df0deb90 746yelp at foo line 30.
0453d815
PM
747########
748# toke.c
0453d815 749my $a = rand + 4 ;
fbdd83da
DIM
750$a = rand *^H ;
751$a = rand $^H ;
0453d815 752EXPECT
2d5ccbba 753Warning: Use of "rand" without parentheses is ambiguous at - line 2.
0453d815
PM
754########
755# toke.c
756$^W = 0 ;
757my $a = rand + 4 ;
758{
4438c4b7 759 no warnings 'ambiguous' ;
0453d815 760 $a = rand + 4 ;
4438c4b7 761 use warnings 'ambiguous' ;
0453d815
PM
762 $a = rand + 4 ;
763}
764$a = rand + 4 ;
765EXPECT
2d5ccbba
IT
766Warning: Use of "rand" without parentheses is ambiguous at - line 3.
767Warning: Use of "rand" without parentheses is ambiguous at - line 8.
768Warning: Use of "rand" without parentheses is ambiguous at - line 10.
0453d815 769########
e19a021b
FC
770# [perl #97110]
771sub myrand(;$) { }
b5fb7ce3 772sub whatever($) { }
e19a021b 773my $a = myrand + 4 ;
b5fb7ce3 774my $b = whatever + 4 ;
e19a021b 775EXPECT
b5fb7ce3 776Warning: Use of "myrand" without parentheses is ambiguous at - line 4.
e19a021b 777########
0453d815 778# toke.c
e8ae98db
RGS
779use warnings "ambiguous";
780print for keys %+; # should not warn
781EXPECT
782########
783# toke.c
0453d815
PM
784sub fred {};
785-fred ;
898c3bca
FC
786sub hank : lvalue {$_}
787--hank; # This should *not* warn [perl #77240]
0453d815
PM
788EXPECT
789Ambiguous use of -fred resolved as -&fred() at - line 3.
790########
791# toke.c
792$^W = 0 ;
793sub fred {} ;
794-fred ;
795{
4438c4b7 796 no warnings 'ambiguous' ;
0453d815 797 -fred ;
4438c4b7 798 use warnings 'ambiguous' ;
0453d815
PM
799 -fred ;
800}
801-fred ;
802EXPECT
803Ambiguous use of -fred resolved as -&fred() at - line 4.
804Ambiguous use of -fred resolved as -&fred() at - line 9.
805Ambiguous use of -fred resolved as -&fred() at - line 11.
806########
807# toke.c
43b5ab4c
BF
808use utf8;
809use open qw( :utf8 :std );
810sub frèd {};
811-frèd ;
812EXPECT
813Ambiguous use of -frèd resolved as -&frèd() at - line 5.
814########
815# toke.c
816$^W = 0 ;
817use utf8;
818use open qw( :utf8 :std );
819sub frèd {} ;
820-frèd ;
821{
822 no warnings 'ambiguous' ;
823 -frèd ;
824 use warnings 'ambiguous' ;
825 -frèd ;
826}
827-frèd ;
828EXPECT
829Ambiguous use of -frèd resolved as -&frèd() at - line 6.
830Ambiguous use of -frèd resolved as -&frèd() at - line 11.
831Ambiguous use of -frèd resolved as -&frèd() at - line 13.
832########
833# toke.c
834use utf8;
835use open qw( :utf8 :std );
836sub ᒍᒘᒊ {};
837-ᒍᒘᒊ ;
838EXPECT
839Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 5.
840########
841# toke.c
842$^W = 0 ;
843use utf8;
844use open qw( :utf8 :std );
845sub ᒍᒘᒊ {} ;
846-ᒍᒘᒊ ;
847{
848 no warnings 'ambiguous' ;
849 -ᒍᒘᒊ ;
850 use warnings 'ambiguous' ;
851 -ᒍᒘᒊ ;
852}
853-ᒍᒘᒊ ;
854EXPECT
855Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 6.
856Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 11.
857Ambiguous use of -ᒍᒘᒊ resolved as -&ᒍᒘᒊ() at - line 13.
858########
859# toke.c
0453d815 860open FOO || time;
240d1b6f 861open local *FOO; # should be ok
0453d815
PM
862EXPECT
863Precedence problem: open FOO should be open(FOO) at - line 2.
864########
71aa9713
BF
865# toke.c
866use utf8;
867use open qw( :utf8 :std );
868open FÒÒ || time;
869EXPECT
870Precedence problem: open FÒÒ should be open(FÒÒ) at - line 4.
871########
872# toke.c
873use utf8;
874use open qw( :utf8 :std );
875open ᒍOO || time;
876EXPECT
877Precedence problem: open ᒍOO should be open(ᒍOO) at - line 4.
878########
66fbe8fb
HS
879# toke.c (and [perl #16184])
880open FOO => "<&0"; close FOO;
881EXPECT
882########
0453d815
PM
883# toke.c
884$^W = 0 ;
885open FOO || time;
886{
e476b1b5 887 no warnings 'precedence' ;
0453d815 888 open FOO || time;
e476b1b5 889 use warnings 'precedence' ;
0453d815
PM
890 open FOO || time;
891}
892open FOO || time;
db3abe52 893open Foo::BAR; # this should not warn
0453d815
PM
894EXPECT
895Precedence problem: open FOO should be open(FOO) at - line 3.
896Precedence problem: open FOO should be open(FOO) at - line 8.
897Precedence problem: open FOO should be open(FOO) at - line 10.
898########
899# toke.c
900$^W = 0 ;
71aa9713
BF
901use utf8;
902use open qw( :utf8 :std );
903open FÒÒ || time;
904{
905 no warnings 'precedence' ;
906 open FÒÒ || time;
907 use warnings 'precedence' ;
908 open FÒÒ || time;
909}
910open FÒÒ || time;
911EXPECT
912Precedence problem: open FÒÒ should be open(FÒÒ) at - line 5.
913Precedence problem: open FÒÒ should be open(FÒÒ) at - line 10.
914Precedence problem: open FÒÒ should be open(FÒÒ) at - line 12.
915########
916# toke.c
917use utf8;
918use open qw( :utf8 :std );
919$^W = 0 ;
920open ᒍÒÒ || time;
921{
922 no warnings 'precedence' ;
923 open ᒍÒÒ || time;
924 use warnings 'precedence' ;
925 open ᒍÒÒ || time;
926}
927open ᒍÒÒ || time;
928EXPECT
929Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 5.
930Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 10.
931Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 12.
932########
933# toke.c
934$^W = 0 ;
0453d815
PM
935*foo *foo ;
936{
4438c4b7 937 no warnings 'ambiguous' ;
0453d815 938 *foo *foo ;
4438c4b7 939 use warnings 'ambiguous' ;
0453d815
PM
940 *foo *foo ;
941}
942*foo *foo ;
9700e2d3
FC
943# These should not warn [perl #117535]:
944foo**foo ;
945no warnings 'deprecated';
946sort $*foo ;
947sort $ *foo ;
0453d815
PM
948EXPECT
949Operator or semicolon missing before *foo at - line 3.
950Ambiguous use of * resolved as operator * at - line 3.
951Operator or semicolon missing before *foo at - line 8.
952Ambiguous use of * resolved as operator * at - line 8.
953Operator or semicolon missing before *foo at - line 10.
954Ambiguous use of * resolved as operator * at - line 10.
767a6a26
PM
955########
956# toke.c
9700e2d3
FC
957$^W = 0 ;
958%foo %foo ;
959{
960 no warnings 'ambiguous' ;
961 %foo %foo ;
962 use warnings 'ambiguous' ;
963 %foo %foo ;
964}
965%foo %foo ;
966# This should not produce ambiguity warnings [perl #117535]:
967sort $%foo ;
968sort $ %foo ;
969EXPECT
970Operator or semicolon missing before %foo at - line 3.
971Ambiguous use of % resolved as operator % at - line 3.
972Operator or semicolon missing before %foo at - line 8.
973Ambiguous use of % resolved as operator % at - line 8.
974Operator or semicolon missing before %foo at - line 10.
975Ambiguous use of % resolved as operator % at - line 10.
976Bareword found where operator expected at - line 12, near "$%foo"
977 (Missing operator before foo?)
978Bareword found where operator expected at - line 13, near "$ %foo"
979 (Missing operator before foo?)
980Illegal modulus zero at - line 3.
981########
982# toke.c
983$^W = 0 ;
984&foo &foo ;
985{
986 no warnings 'ambiguous' ;
987 &foo &foo ;
988 use warnings 'ambiguous' ;
989 &foo &foo ;
990}
991&foo &foo ;
992# These should not warn produce ambiguity warnings [perl #76910]:
993foo&&foo ;
994sort $&foo ;
995sort $ &foo ;
996EXPECT
997Operator or semicolon missing before &foo at - line 3.
998Ambiguous use of & resolved as operator & at - line 3.
999Operator or semicolon missing before &foo at - line 8.
1000Ambiguous use of & resolved as operator & at - line 8.
1001Operator or semicolon missing before &foo at - line 10.
1002Ambiguous use of & resolved as operator & at - line 10.
1003Bareword found where operator expected at - line 13, near "$&foo"
1004 (Missing operator before foo?)
1005Bareword found where operator expected at - line 14, near "$ &foo"
1006 (Missing operator before foo?)
1007Undefined subroutine &main::foo called at - line 3.
1008########
1009# toke.c
02571fe8
BF
1010use utf8;
1011use open qw( :utf8 :std );
1012$^W = 0 ;
1013*foo *foo ;
1014{
1015 no warnings 'ambiguous' ;
1016 *foo *foo ;
1017 use warnings 'ambiguous' ;
1018 *foo *foo ;
1019}
1020*foo *foo ;
1021EXPECT
1022Operator or semicolon missing before *foo at - line 5.
1023Ambiguous use of * resolved as operator * at - line 5.
1024Operator or semicolon missing before *foo at - line 10.
1025Ambiguous use of * resolved as operator * at - line 10.
1026Operator or semicolon missing before *foo at - line 12.
1027Ambiguous use of * resolved as operator * at - line 12.
1028########
1029# toke.c
e476b1b5 1030use warnings 'misc' ;
767a6a26 1031my $a = "\m" ;
e476b1b5 1032no warnings 'misc' ;
767a6a26
PM
1033$a = "\m" ;
1034EXPECT
1035Unrecognized escape \m passed through at - line 3.
1036########
1037# toke.c
52ed07f6
BF
1038use warnings 'misc' ;
1039my $a = "abcd\E" ;
1040no warnings 'misc' ;
1041$a = "abcd\E" ;
1042EXPECT
820438b1 1043Useless use of \E at - line 3.
52ed07f6
BF
1044########
1045# toke.c
1f25714a
FC
1046use feature 'postderef', 'postderef_qq';
1047(\$_)->$*;
1048"$_->$*";
1049no warnings 'experimental::postderef';
1050(\$_)->$*;
1051"$_->$*";
1052EXPECT
1053Postfix dereference is experimental at - line 3.
1054Postfix dereference is experimental at - line 4.
1055########
1056# toke.c
767a6a26
PM
1057use warnings 'portable' ;
1058my $a = 0b011111111111111111111111111111110 ;
1059 $a = 0b011111111111111111111111111111111 ;
1060 $a = 0b111111111111111111111111111111111 ;
1061 $a = 0x0fffffffe ;
1062 $a = 0x0ffffffff ;
1063 $a = 0x1ffffffff ;
1064 $a = 0037777777776 ;
1065 $a = 0037777777777 ;
1066 $a = 0047777777777 ;
1067no warnings 'portable' ;
1068 $a = 0b011111111111111111111111111111110 ;
1069 $a = 0b011111111111111111111111111111111 ;
1070 $a = 0b111111111111111111111111111111111 ;
1071 $a = 0x0fffffffe ;
1072 $a = 0x0ffffffff ;
1073 $a = 0x1ffffffff ;
1074 $a = 0037777777776 ;
1075 $a = 0037777777777 ;
1076 $a = 0047777777777 ;
1077EXPECT
1078Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
1079Hexadecimal number > 0xffffffff non-portable at - line 8.
1080Octal number > 037777777777 non-portable at - line 11.
1081########
1082# toke.c
1083use warnings 'overflow' ;
1084my $a = 0b011111111111111111111111111111110 ;
1085 $a = 0b011111111111111111111111111111111 ;
15041a67 1086 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
1087 $a = 0x0fffffffe ;
1088 $a = 0x0ffffffff ;
15041a67 1089 $a = 0x10000000000000000 ;
767a6a26
PM
1090 $a = 0037777777776 ;
1091 $a = 0037777777777 ;
15041a67 1092 $a = 002000000000000000000000;
767a6a26
PM
1093no warnings 'overflow' ;
1094 $a = 0b011111111111111111111111111111110 ;
1095 $a = 0b011111111111111111111111111111111 ;
15041a67 1096 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
1097 $a = 0x0fffffffe ;
1098 $a = 0x0ffffffff ;
15041a67 1099 $a = 0x10000000000000000 ;
767a6a26
PM
1100 $a = 0037777777776 ;
1101 $a = 0037777777777 ;
15041a67 1102 $a = 002000000000000000000000;
767a6a26
PM
1103EXPECT
1104Integer overflow in binary number at - line 5.
1105Integer overflow in hexadecimal number at - line 8.
1106Integer overflow in octal number at - line 11.
8593bda5
GS
1107########
1108# toke.c
ac206dc8
RGS
1109BEGIN { $^C = 1; }
1110use warnings 'misc';
1111dump;
1112CORE::dump;
1113EXPECT
1114dump() better written as CORE::dump() at - line 4.
1115- syntax OK
1116########
1117# toke.c
1118use warnings 'misc';
1119use subs qw/dump/;
93f09d7b 1120sub dump { print "no warning for overridden dump\n"; }
ac206dc8
RGS
1121dump;
1122EXPECT
93f09d7b 1123no warning for overridden dump
ac206dc8
RGS
1124########
1125# toke.c
8593bda5
GS
1126use warnings 'ambiguous';
1127"@mjd_previously_unused_array";
1128no warnings 'ambiguous';
29fb1d0e 1129"@mjd_previously_unused_array2";
8593bda5
GS
1130EXPECT
1131Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.
707afd92
MS
1132########
1133# toke.c
29fb1d0e
BF
1134use utf8;
1135use open qw( :utf8 :std );
1136use warnings 'ambiguous';
1137"@mjd_previously_unused_àrray";
1138no warnings 'ambiguous';
1139"@mjd_previously_unused_àrray2";
1140EXPECT
1141Possible unintended interpolation of @mjd_previously_unused_àrray in string at - line 5.
1142########
1143# toke.c
1144use utf8;
1145use open qw( :utf8 :std );
1146use warnings 'ambiguous';
1147"@mjd_previously_unused_ぁrrぁy";
1148no warnings 'ambiguous';
1149"@mjd_previously_unused_ぁrrぁy2";
1150EXPECT
1151Possible unintended interpolation of @mjd_previously_unused_ぁrrぁy in string at - line 5.
1152########
1153# toke.c
d8c55666 1154# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
1155use warnings 'regexp';
1156"foo" =~ /foo/c;
64e578a2 1157"foo" =~ /foo/cg;
4ac733c9
MJD
1158no warnings 'regexp';
1159"foo" =~ /foo/c;
64e578a2 1160"foo" =~ /foo/cg;
4ac733c9
MJD
1161EXPECT
1162Use of /c modifier is meaningless without /g at - line 4.
1163########
1164# toke.c
d8c55666 1165# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
1166use warnings 'regexp';
1167$_ = "ab" ;
1168s/ab/ab/c;
64e578a2 1169s/ab/ab/cg;
4ac733c9
MJD
1170no warnings 'regexp';
1171s/ab/ab/c;
64e578a2 1172s/ab/ab/cg;
4ac733c9 1173EXPECT
64e578a2
MJD
1174Use of /c modifier is meaningless in s/// at - line 5.
1175Use of /c modifier is meaningless in s/// at - line 6.
d8c55666
MJD
1176########
1177-wa
1178# toke.c
1179# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
1180print "@F\n";
1181EXPECT
1182
1183########
1184-w
1185# toke.c
1186# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
1187print "@F\n";
1188EXPECT
1189Possible unintended interpolation of @F in string at - line 4.
1190Name "main::F" used only once: possible typo at - line 4.
1191########
1192-wa
1193# toke.c
1194# 20020414 mjd-perl-patch+@plover.com
1195EXPECT
1196
2710853f
MJD
1197########
1198# toke.c
1199# 20020414 mjd-perl-patch+@plover.com
1200# In 5.7.3, this emitted "Possible unintended interpolation" warnings
1201use warnings 'ambiguous';
1202$s = "(@-)(@+)";
1203EXPECT
1204
56da5a46
RGS
1205########
1206# toke.c
1207# mandatory warning
1208eval q/if ($a) { } elseif ($b) { }/;
1209no warnings "syntax";
1210eval q/if ($a) { } elseif ($b) { }/;
1211EXPECT
1212elseif should be elsif at (eval 1) line 1.
1213########
1214# toke.c
1215# mandatory warning
1216eval q/5 6/;
1217no warnings "syntax";
1218eval q/5 6/;
1219EXPECT
1220Number found where operator expected at (eval 1) line 1, near "5 6"
1221 (Missing operator before 6?)
984200d0
YST
1222########
1223# toke.c
7fc874e8 1224use warnings "syntax"; no warnings "deprecated";
984200d0
YST
1225$_ = $a = 1;
1226$a !=~ /1/;
1227$a !=~ m#1#;
1228$a !=~/1/;
1229$a !=~ ?/?;
decca21c
YST
1230$a !=~ y/1//;
1231$a !=~ tr/1//;
1232$a !=~ s/1//;
984200d0
YST
1233$a != ~/1/;
1234no warnings "syntax";
1235$a !=~ /1/;
1236$a !=~ m#1#;
1237$a !=~/1/;
1238$a !=~ ?/?;
decca21c
YST
1239$a !=~ y/1//;
1240$a !=~ tr/1//;
1241$a !=~ s/1//;
984200d0
YST
1242EXPECT
1243!=~ should be !~ at - line 4.
1244!=~ should be !~ at - line 5.
1245!=~ should be !~ at - line 6.
1246!=~ should be !~ at - line 7.
decca21c
YST
1247!=~ should be !~ at - line 8.
1248!=~ should be !~ at - line 9.
1249!=~ should be !~ at - line 10.
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;
1351my $a = "foo";
1352print $a =~ ?f? ? "yes\n" : "no\n" foreach 0..2;
1353EXPECT
1354Use of ?PATTERN? without explicit operator is deprecated at - line 4.
1355yes
1356no
1357no
17a3df4c
KW
1358########
1359# toke.c
1360use warnings;
1361my $a = "\c{ack}";
1362$a = "\c,";
1363$a = "\c`";
1364no warnings 'syntax';
1365$a = "\c{ack}";
1366$a = "\c,";
1367$a = "\c`";
1368no warnings 'deprecated';
1369EXPECT
1370"\c{" is deprecated and is more clearly written as ";" at - line 3.
1371"\c," is more clearly written simply as "l" at - line 4.
1372"\c`" is more clearly written simply as "\ " at - line 5.
1373"\c{" is deprecated and is more clearly written as ";" at - line 7.
3955e1a9
KW
1374########
1375# toke.c
1376use warnings 'syntax' ;
1377my $a = qr/foo/du;
ff3f26d2 1378$a = qr/foo/lai;
3955e1a9 1379$a = qr/foo/lil;
ff3f26d2
KW
1380$a = qr/foo/aia;
1381$a = qr/foo/aaia;
3955e1a9
KW
1382no warnings 'syntax' ;
1383my $a = qr/foo/du;
1384EXPECT
1385Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= "
1386Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= "
1387Regexp modifier "/l" may not appear twice at - line 5, near "= "
ff3f26d2
KW
1388Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= "
1389BEGIN not safe after errors--compilation aborted at - line 8.
ba05d9aa
FC
1390########
1391# toke.c
1392# [perl #4362]
1393eval "print q\xabfoo";
1394print "ok\n" if
1395 $@ =~ /Can't find string terminator "\xab" anywhere before EOF/;
1396EXPECT
1397ok
5c66c3dd
BF
1398########
1399# toke.c
1400use utf8;
1401use open qw( :utf8 :std );
1402use warnings 'ambiguous' ;
1403sub frèd {}
1404$a = ${frèd} ;
1405no warnings 'ambiguous' ;
1406$a = ${frèd} ;
1407EXPECT
1408Ambiguous use of ${frèd} resolved to $frèd at - line 6.
1409########
1410# toke.c
1411use utf8;
1412use open qw( :utf8 :std );
1413use warnings 'ambiguous' ;
1414sub f렏 {}
1415$a = ${f렏} ;
1416no warnings 'ambiguous' ;
1417$a = ${f렏} ;
1418EXPECT
1419Ambiguous use of ${f렏} resolved to $f렏 at - line 6.
3773592b
BF
1420########
1421# toke.c
1422use utf8;
1423use open qw( :utf8 :std );
1424use warnings;
1425CORE::렏;
1426EXPECT
1427CORE::렏 is not a keyword at - line 5.
5dc13276
MH
1428########
1429# toke.c
1430# [perl #16249]
1431print '';
1432eval this_method_is_fake ();
1433EXPECT
1434Undefined subroutine &main::this_method_is_fake called at - line 4.
a71a1afb
FC
1435########
1436# toke.c
1437# [perl #107002] Erroneous ambiguity warnings
1438sub { # do not actually call require
1439 require a::b . 1; # These used to produce erroneous
1440 require a::b + 1; # ambiguity warnings.
1441}
1442EXPECT
4d68ffa0
KW
1443########
1444# toke.c
70502ce0 1445# [perl #113094], [perl #119101]
4d68ffa0
KW
1446print "aa" =~ m{^a\{1,2\}$}, "\n";
1447print "aa" =~ m{^a\x\{61\}$}, "\n";
70502ce0
KW
1448print "a\\x{6F}" =~ m{^a\\x\{6F\}$}, "\n";
1449print "a\\o" =~ m{^a\\\x\{6F\}$}, "\n";
1450print "a\\\\x{6F}" =~ m{^a\\\\x\{6F\}$}, "\n";
1451print "a\\\\o" =~ m{^a\\\\\x\{6F\}$}, "\n";
4d68ffa0
KW
1452print "aa" =~ m{^a{1,2}$}, "\n";
1453print "aq" =~ m[^a\[a-z\]$], "\n";
1454print "aq" =~ m(^a\(q\)$), "\n";
1455no warnings 'deprecated';
1456print "aa" =~ m{^a\{1,2\}$}, "\n";
1457print "aa" =~ m{^a\x\{61\}$}, "\n";
70502ce0
KW
1458print "a\\x{6F}" =~ m{^a\\x\{6F\}$}, "\n";
1459print "a\\o" =~ m{^a\\\x\{6f\}$}, "\n";
4d68ffa0
KW
1460print "aq" =~ m[^a\[a-z\]$], "\n";
1461print "aq" =~ m(^a\(q\)$), "\n";
1462EXPECT
1463Useless use of '\'; doesn't escape metacharacter '{' at - line 3.
1464Useless use of '\'; doesn't escape metacharacter '{' at - line 4.
70502ce0
KW
1465Useless use of '\'; doesn't escape metacharacter '{' at - line 6.
1466Useless use of '\'; doesn't escape metacharacter '{' at - line 8.
1467Useless use of '\'; doesn't escape metacharacter '[' at - line 10.
1468Useless use of '\'; doesn't escape metacharacter '(' at - line 11.
14691
14701
14711
14721
4d68ffa0
KW
14731
14741
14751
14761
1477q
14781
14791
14801
70502ce0
KW
14811
14821
4d68ffa0 1483q
b29f65fc
BF
1484########
1485# toke.c
1486#[perl #119123] disallow literal control character variables
1487eval "\$\cQ = 25";
1488eval "\${ \cX } = 24";
1489*{
1490 Foo
1491}; # shouldn't warn on {\n, even though \n is a control character
1492EXPECT
1493Use of literal control characters in variable names is deprecated at (eval 1) line 1.
1494Use of literal control characters in variable names is deprecated at (eval 2) line 1.
46879fad
DM
1495########
1496# toke.c
1497# [perl #120288] -X at start of line gave spurious warning, where X is not
1498# a filetest operator
1499-a;
1500;-a;
1501EXPECT