This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test for [perl #130567]
[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 6 $a = <<;
6ef4f8b7 7 Use of comma-less variable list is deprecated. Its use will be fatal in Perl 5.28
599cee73
PM
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
6ef4f8b7
A
139Use of comma-less variable list is deprecated. Its use will be fatal in Perl 5.28 at - line 4.
140Use of comma-less variable list is deprecated. Its use will be fatal in Perl 5.28 at - line 4.
141Use of comma-less variable list is deprecated. Its use will be fatal in Perl 5.28 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
e5aa3f0b 150Use of bare << to mean <<"" is deprecated. Its use will be fatal in Perl 5.28 at - line 2.
0da72d5e
KW
151########
152# toke.c
cdd6375d
MH
153$a = <<~;
154
155$a = <<~ ;
156
157EXPECT
e5aa3f0b
A
158Use of bare << to mean <<"" is deprecated. Its use will be fatal in Perl 5.28 at - line 2.
159Use of bare << to mean <<"" is deprecated. Its use will be fatal in Perl 5.28 at - line 4.
cdd6375d
MH
160########
161# toke.c
0da72d5e
KW
162$a =~ m/$foo/eq;
163$a =~ s/$foo/fool/seq;
164
165EXPECT
166OPTION fatal
167Unknown regexp modifier "/e" at - line 2, near "=~ "
168Unknown regexp modifier "/q" at - line 2, near "=~ "
169Unknown regexp modifier "/q" at - line 3, near "=~ "
170Execution of - aborted due to compilation errors.
84159251
BF
171########
172# toke.c
173use utf8;
174use open qw( :utf8 :std );
175$a =~ m/$foo/eネq;
176$a =~ s/$foo/fool/seネq;
177
178EXPECT
179OPTION fatal
180Unknown regexp modifier "/e" at - line 4, near "=~ "
181Unknown regexp modifier "/ネ" at - line 4, near "=~ "
182Unknown regexp modifier "/q" at - line 4, near "=~ "
183Unknown regexp modifier "/ネ" at - line 5, near "=~ "
184Unknown regexp modifier "/q" at - line 5, near "=~ "
185Execution of - aborted due to compilation errors.
599cee73
PM
186########
187# toke.c
4438c4b7 188use warnings 'syntax' ;
599cee73 189s/(abc)/\1/;
4438c4b7 190no warnings 'syntax' ;
0453d815 191s/(abc)/\1/;
599cee73
PM
192EXPECT
193\1 better written as $1 at - line 3.
194########
195# toke.c
4438c4b7 196use warnings 'semicolon' ;
599cee73
PM
197$a = 1
198&time ;
4438c4b7 199no warnings 'semicolon' ;
0453d815
PM
200$a = 1
201&time ;
599cee73
PM
202EXPECT
203Semicolon seems to be missing at - line 3.
204########
205# toke.c
4438c4b7 206use warnings 'syntax' ;
599cee73
PM
207my $a =+ 2 ;
208$a =- 2 ;
209$a =* 2 ;
210$a =% 2 ;
211$a =& 2 ;
212$a =. 2 ;
213$a =^ 2 ;
214$a =| 2 ;
215$a =< 2 ;
216$a =/ 2 ;
217EXPECT
7f01dc7a
JH
218Reversed += operator at - line 3.
219Reversed -= operator at - line 4.
220Reversed *= operator at - line 5.
221Reversed %= operator at - line 6.
222Reversed &= operator at - line 7.
223Reversed .= operator at - line 8.
224Reversed ^= operator at - line 9.
225Reversed |= operator at - line 10.
226Reversed <= operator at - line 11.
227syntax error at - line 8, near "=."
228syntax error at - line 9, near "=^"
229syntax error at - line 10, near "=|"
230Unterminated <> operator at - line 11.
599cee73
PM
231########
232# toke.c
4438c4b7 233no warnings 'syntax' ;
0453d815
PM
234my $a =+ 2 ;
235$a =- 2 ;
236$a =* 2 ;
237$a =% 2 ;
238$a =& 2 ;
239$a =. 2 ;
240$a =^ 2 ;
241$a =| 2 ;
242$a =< 2 ;
243$a =/ 2 ;
244EXPECT
7f01dc7a
JH
245syntax error at - line 8, near "=."
246syntax error at - line 9, near "=^"
247syntax error at - line 10, near "=|"
248Unterminated <> operator at - line 11.
0453d815
PM
249########
250# toke.c
4438c4b7 251use warnings 'syntax' ;
599cee73 252my $a = $a[1,2] ;
4438c4b7 253no warnings 'syntax' ;
0453d815 254my $a = $a[1,2] ;
599cee73
PM
255EXPECT
256Multidimensional syntax $a[1,2] not supported at - line 3.
257########
258# toke.c
4438c4b7 259use warnings 'syntax' ;
599cee73 260sub fred {} ; $SIG{TERM} = fred;
4438c4b7 261no warnings 'syntax' ;
0453d815 262$SIG{TERM} = fred;
599cee73
PM
263EXPECT
264You need to quote "fred" at - line 3.
265########
266# toke.c
4c01a014
BF
267use utf8;
268use open qw( :utf8 :std );
269use warnings 'syntax' ;
270sub frèd {} ; $SIG{TERM} = frèd;
271no warnings 'syntax' ;
272$SIG{TERM} = frèd;
273EXPECT
274You need to quote "frèd" at - line 5.
275########
276# toke.c
277use utf8;
278use open qw( :utf8 :std );
279use warnings 'syntax' ;
280sub ふれど {} ; $SIG{TERM} = ふれど;
281no warnings 'syntax' ;
282$SIG{TERM} = ふれど;
283EXPECT
284You need to quote "ふれど" at - line 5.
285########
286# toke.c
4438c4b7 287use warnings 'syntax' ;
599cee73
PM
288$_ = "ab" ;
289s/(ab)/\1/e;
e37958c3
FC
290s//\(2)/e; # should be exempt
291s/${\2}//; # same here
292()="${\2}"; # metoo
4438c4b7 293no warnings 'syntax' ;
0453d815
PM
294$_ = "ab" ;
295s/(ab)/\1/e;
599cee73
PM
296EXPECT
297Can't use \1 to mean $1 in expression at - line 4.
298########
299# toke.c
4438c4b7 300use warnings 'reserved' ;
599cee73 301$a = abc;
1c3923b3
GS
302$a = { def
303
304=> 1 };
4438c4b7 305no warnings 'reserved' ;
0453d815 306$a = abc;
599cee73
PM
307EXPECT
308Unquoted string "abc" may clash with future reserved word at - line 3.
309########
310# toke.c
e476b1b5 311use warnings 'qw' ;
599cee73 312@a = qw(a, b, c) ;
e476b1b5 313no warnings 'qw' ;
0453d815 314@a = qw(a, b, c) ;
599cee73
PM
315EXPECT
316Possible attempt to separate words with commas at - line 3.
317########
318# toke.c
e476b1b5 319use warnings 'qw' ;
7e03b518 320@a = qw(a b c # #) ;
e476b1b5 321no warnings 'qw' ;
7e03b518 322@a = qw(a b c # #) ;
599cee73
PM
323EXPECT
324Possible attempt to put comments in qw() list at - line 3.
325########
326# toke.c
7e03b518
EB
327use warnings 'qw' ;
328@a = qw(a, b, c # #) ;
329no warnings 'qw' ;
330@a = qw(a, b, c # #) ;
331EXPECT
332Possible attempt to separate words with commas at - line 3.
333Possible attempt to put comments in qw() list at - line 3.
334########
335# toke.c
4438c4b7 336use warnings 'syntax' ;
b1439985
RGS
337print ("");
338print ("") and $x = 1;
339print ("") or die;
340print ("") // die;
341print (1+2) * 3 if 0; # only this one should warn
342print (1+2) if 0;
599cee73 343EXPECT
b1439985 344print (...) interpreted as function at - line 7.
599cee73
PM
345########
346# toke.c
4438c4b7 347no warnings 'syntax' ;
0453d815
PM
348print ("")
349EXPECT
350
351########
352# toke.c
4438c4b7 353use warnings 'syntax' ;
b1439985
RGS
354printf ("");
355printf ("") . '';
599cee73 356EXPECT
b1439985 357printf (...) interpreted as function at - line 4.
599cee73
PM
358########
359# toke.c
4438c4b7 360no warnings 'syntax' ;
0453d815
PM
361printf ("")
362EXPECT
363
364########
365# toke.c
4438c4b7 366use warnings 'syntax' ;
b1439985
RGS
367sort ("");
368sort ("") . '';
599cee73 369EXPECT
b1439985 370sort (...) interpreted as function at - line 4.
599cee73
PM
371########
372# toke.c
4438c4b7 373no warnings 'syntax' ;
0453d815
PM
374sort ("")
375EXPECT
376
377########
378# toke.c
4438c4b7 379use warnings 'ambiguous' ;
599cee73 380$a = ${time[2]};
4438c4b7 381no warnings 'ambiguous' ;
0453d815 382$a = ${time[2]};
599cee73
PM
383EXPECT
384Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
385########
386# toke.c
4438c4b7 387use warnings 'ambiguous' ;
599cee73
PM
388$a = ${time{2}};
389EXPECT
390Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
391########
392# toke.c
a49b10d0
BF
393use warnings 'ambiguous' ;
394$a = ${
395
396 time
397 {2}
398};
399warn "after";
400EXPECT
401Ambiguous use of ${time{...}} resolved to $time{...} at - line 5.
402after at - line 8.
403########
404# toke.c
405use warnings 'ambiguous' ;
406$a = ${
407
408time[2]
409
410};
411$a = ${
412
413time
414 [2]
415
416};
417warn "after";
418EXPECT
419Ambiguous use of ${time[...]} resolved to $time[...] at - line 5.
420Ambiguous use of ${time[...]} resolved to $time[...] at - line 10.
421after at - line 14.
422########
423# toke.c
4438c4b7 424no warnings 'ambiguous' ;
0453d815
PM
425$a = ${time{2}};
426EXPECT
427
428########
429# toke.c
4438c4b7 430use warnings 'ambiguous' ;
599cee73 431$a = ${time} ;
27ffb73a
NC
432$a = @{time} ;
433$a = $#{time} ; # This one is special cased in toke.c
434$a = %{time} ;
435$a = *{time} ;
436$a = defined &{time} ; # To avoid calling &::time
4438c4b7 437no warnings 'ambiguous' ;
0453d815 438$a = ${time} ;
27ffb73a
NC
439$a = @{time} ;
440$a = $#{time} ; # This one is special cased in toke.c
441$a = %{time} ;
442$a = *{time} ;
443$a = defined &{time} ; # To avoid calling &::time
599cee73
PM
444EXPECT
445Ambiguous use of ${time} resolved to $time at - line 3.
27ffb73a
NC
446Ambiguous use of @{time} resolved to @time at - line 4.
447Ambiguous use of @{time} resolved to @time at - line 5.
448Ambiguous use of %{time} resolved to %time at - line 6.
449Ambiguous use of *{time} resolved to *time at - line 7.
450Ambiguous use of &{time} resolved to &time at - line 8.
599cee73
PM
451########
452# toke.c
4438c4b7 453use warnings 'ambiguous' ;
a49b10d0
BF
454$a = ${
455time
456} ;
457$a = @{
458time
459} ;
460$a = $#{
461time
462} ;
463$a = %{
464time
465} ;
466$a = *{
467time
468} ;
469$a = defined &{
470time
471
472
473} ;
474warn "last";
475EXPECT
476Ambiguous use of ${time} resolved to $time at - line 4.
477Ambiguous use of @{time} resolved to @time at - line 7.
478Ambiguous use of @{time} resolved to @time at - line 10.
479Ambiguous use of %{time} resolved to %time at - line 13.
480Ambiguous use of *{time} resolved to *time at - line 16.
481Ambiguous use of &{time} resolved to &time at - line 19.
482last at - line 23.
483########
484# toke.c
485use warnings 'ambiguous' ;
599cee73
PM
486sub fred {}
487$a = ${fred} ;
4438c4b7 488no warnings 'ambiguous' ;
0453d815 489$a = ${fred} ;
599cee73
PM
490EXPECT
491Ambiguous use of ${fred} resolved to $fred at - line 4.
492########
493# toke.c
4438c4b7 494use warnings 'syntax' ;
7fd134d9
JH
495$a = _123; print "$a\n"; #( 3 string)
496$a = 1_23; print "$a\n";
497$a = 12_3; print "$a\n";
498$a = 123_; print "$a\n"; # 6
499$a = _+123; print "$a\n"; # 7 string)
500$a = +_123; print "$a\n"; #( 8 string)
501$a = +1_23; print "$a\n";
502$a = +12_3; print "$a\n";
503$a = +123_; print "$a\n"; # 11
504$a = _-123; print "$a\n"; #(12 string)
505$a = -_123; print "$a\n"; #(13 string)
506$a = -1_23; print "$a\n";
507$a = -12_3; print "$a\n";
508$a = -123_; print "$a\n"; # 16
509$a = 123._456; print "$a\n"; # 17
510$a = 123.4_56; print "$a\n";
511$a = 123.45_6; print "$a\n";
512$a = 123.456_; print "$a\n"; # 20
513$a = +123._456; print "$a\n"; # 21
514$a = +123.4_56; print "$a\n";
515$a = +123.45_6; print "$a\n";
516$a = +123.456_; print "$a\n"; # 24
517$a = -123._456; print "$a\n"; # 25
518$a = -123.4_56; print "$a\n";
519$a = -123.45_6; print "$a\n";
520$a = -123.456_; print "$a\n"; # 28
2bea9a37
JH
521$a = 123.456E_12; printf("%.0f\n", $a); # 29
522$a = 123.456E1_2; printf("%.0f\n", $a);
523$a = 123.456E12_; printf("%.0f\n", $a); # 31
524$a = 123.456E_+12; printf("%.0f\n", $a); # 32
525$a = 123.456E+_12; printf("%.0f\n", $a); # 33
526$a = 123.456E+1_2; printf("%.0f\n", $a);
527$a = 123.456E+12_; printf("%.0f\n", $a); # 35
7fd134d9
JH
528$a = 123.456E_-12; print "$a\n"; # 36
529$a = 123.456E-_12; print "$a\n"; # 37
530$a = 123.456E-1_2; print "$a\n";
531$a = 123.456E-12_; print "$a\n"; # 39
b3b48e3e
JH
532$a = 1__23; print "$a\n"; # 40
533$a = 12.3__4; print "$a\n"; # 41
2bea9a37 534$a = 12.34e1__2; printf("%.0f\n", $a); # 42
4438c4b7 535no warnings 'syntax' ;
7fd134d9
JH
536$a = _123; print "$a\n";
537$a = 1_23; print "$a\n";
538$a = 12_3; print "$a\n";
539$a = 123_; print "$a\n";
540$a = _+123; print "$a\n";
541$a = +_123; print "$a\n";
542$a = +1_23; print "$a\n";
543$a = +12_3; print "$a\n";
544$a = +123_; print "$a\n";
545$a = _-123; print "$a\n";
546$a = -_123; print "$a\n";
547$a = -1_23; print "$a\n";
548$a = -12_3; print "$a\n";
549$a = -123_; print "$a\n";
550$a = 123._456; print "$a\n";
551$a = 123.4_56; print "$a\n";
552$a = 123.45_6; print "$a\n";
553$a = 123.456_; print "$a\n";
554$a = +123._456; print "$a\n";
555$a = +123.4_56; print "$a\n";
556$a = +123.45_6; print "$a\n";
557$a = +123.456_; print "$a\n";
558$a = -123._456; print "$a\n";
559$a = -123.4_56; print "$a\n";
560$a = -123.45_6; print "$a\n";
561$a = -123.456_; print "$a\n";
2bea9a37
JH
562$a = 123.456E_12; printf("%.0f\n", $a);
563$a = 123.456E1_2; printf("%.0f\n", $a);
564$a = 123.456E12_; printf("%.0f\n", $a);
565$a = 123.456E_+12; printf("%.0f\n", $a);
566$a = 123.456E+_12; printf("%.0f\n", $a);
567$a = 123.456E+1_2; printf("%.0f\n", $a);
568$a = 123.456E+12_; printf("%.0f\n", $a);
7fd134d9
JH
569$a = 123.456E_-12; print "$a\n";
570$a = 123.456E-_12; print "$a\n";
571$a = 123.456E-1_2; print "$a\n";
572$a = 123.456E-12_; print "$a\n";
b3b48e3e
JH
573$a = 1__23; print "$a\n";
574$a = 12.3__4; print "$a\n";
2bea9a37 575$a = 12.34e1__2; printf("%.0f\n", $a);
599cee73 576EXPECT
fbfa96bd 577OPTIONS regex
928753ea 578Misplaced _ in number at - line 6.
928753ea 579Misplaced _ in number at - line 11.
7fd134d9 580Misplaced _ in number at - line 16.
928753ea 581Misplaced _ in number at - line 17.
7fd134d9 582Misplaced _ in number at - line 20.
928753ea 583Misplaced _ in number at - line 21.
7fd134d9
JH
584Misplaced _ in number at - line 24.
585Misplaced _ in number at - line 25.
586Misplaced _ in number at - line 28.
587Misplaced _ in number at - line 29.
588Misplaced _ in number at - line 31.
589Misplaced _ in number at - line 32.
590Misplaced _ in number at - line 33.
591Misplaced _ in number at - line 35.
592Misplaced _ in number at - line 36.
593Misplaced _ in number at - line 37.
594Misplaced _ in number at - line 39.
b3b48e3e
JH
595Misplaced _ in number at - line 40.
596Misplaced _ in number at - line 41.
597Misplaced _ in number at - line 42.
928753ea
JH
598_123
599123
928753ea 600123
7fd134d9
JH
601123
602123
603_123
604123
605123
606123
607-123
608-_123
609-123
610-123
611-123
612123.456
613123.456
614123.456
615123.456
616123.456
617123.456
618123.456
619123.456
620-123.456
621-123.456
622-123.456
623-123.456
624123456000000000
625123456000000000
626123456000000000
627123456000000000
628123456000000000
629123456000000000
630123456000000000
fbfa96bd
NIS
6311.23456e-0?10
6321.23456e-0?10
6331.23456e-0?10
6341.23456e-0?10
b3b48e3e
JH
635123
63612.34
63712340000000000
7fd134d9
JH
638_123
639123
640123
641123
642123
643_123
644123
645123
646123
647-123
648-_123
649-123
650-123
651-123
652123.456
653123.456
654123.456
655123.456
656123.456
928753ea
JH
657123.456
658123.456
928753ea 659123.456
7fd134d9
JH
660-123.456
661-123.456
662-123.456
663-123.456
664123456000000000
665123456000000000
666123456000000000
667123456000000000
668123456000000000
669123456000000000
670123456000000000
fbfa96bd
NIS
6711.23456e-0?10
6721.23456e-0?10
6731.23456e-0?10
6741.23456e-0?10
b3b48e3e
JH
675123
67612.34
67712340000000000
599cee73
PM
678########
679# toke.c
72c80c74
Z
680use warnings 'syntax';
681$a = 1_; print "$a\n";
682$a = 01_; print "$a\n";
683$a = 0_; print "$a\n";
684$a = 0x1_; print "$a\n";
685$a = 0x_; print "$a\n";
686$a = 1.2_; print "$a\n";
687$a = 1._2; print "$a\n";
688$a = 1._; print "$a\n";
689EXPECT
690Misplaced _ in number at - line 3.
691Misplaced _ in number at - line 4.
692Misplaced _ in number at - line 5.
693Misplaced _ in number at - line 6.
694Misplaced _ in number at - line 7.
695Misplaced _ in number at - line 8.
696Misplaced _ in number at - line 9.
697Misplaced _ in number at - line 10.
6981
6991
7000
7011
7020
7031.2
7041.2
7051
706########
707# toke.c
e476b1b5 708use warnings 'bareword' ;
60e6418e 709#line 25 "bar"
599cee73 710$a = FRED:: ;
e476b1b5 711no warnings 'bareword' ;
0453d815
PM
712#line 25 "bar"
713$a = FRED:: ;
599cee73 714EXPECT
60e6418e 715Bareword "FRED::" refers to nonexistent package at bar line 25.
979a1401
BF
716########
717# toke.c
718use utf8;
719use open qw( :utf8 :std );
720use warnings 'bareword' ;
721#line 25 "bar"
722$a = FRÈD:: ;
723no warnings 'bareword' ;
724#line 25 "bar"
725$a = FRÈD:: ;
726EXPECT
727Bareword "FRÈD::" refers to nonexistent package at bar line 25.
728########
729# toke.c
730use utf8;
731use open qw( :utf8 :std );
732use warnings 'bareword' ;
733#line 25 "bar"
734$a = ϞϞϞ:: ;
735no warnings 'bareword' ;
736#line 25 "bar"
737$a = ϞϞϞ:: ;
738EXPECT
739Bareword "ϞϞϞ::" refers to nonexistent package at bar line 25.
599cee73
PM
740########
741# toke.c
4438c4b7 742use warnings 'ambiguous' ;
599cee73 743sub time {}
0453d815 744my $a = time() ;
4438c4b7 745no warnings 'ambiguous' ;
0453d815 746my $b = time() ;
599cee73
PM
747EXPECT
748Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
749########
750# toke.c
26d16222 751use warnings ;
0453d815 752eval <<'EOE';
df0deb90
GS
753# line 30 "foo"
754warn "yelp";
0453d815 755{
0453d815
PM
756 $_ = " \x{123} " ;
757}
758EOE
759EXPECT
df0deb90 760yelp at foo line 30.
0453d815
PM
761########
762# toke.c
0453d815 763my $a = rand + 4 ;
fbdd83da
DIM
764$a = rand *^H ;
765$a = rand $^H ;
0453d815 766EXPECT
2d5ccbba 767Warning: Use of "rand" without parentheses is ambiguous at - line 2.
0453d815
PM
768########
769# toke.c
770$^W = 0 ;
771my $a = rand + 4 ;
772{
4438c4b7 773 no warnings 'ambiguous' ;
0453d815 774 $a = rand + 4 ;
4438c4b7 775 use warnings 'ambiguous' ;
0453d815
PM
776 $a = rand + 4 ;
777}
778$a = rand + 4 ;
779EXPECT
2d5ccbba
IT
780Warning: Use of "rand" without parentheses is ambiguous at - line 3.
781Warning: Use of "rand" without parentheses is ambiguous at - line 8.
782Warning: Use of "rand" without parentheses is ambiguous at - line 10.
0453d815 783########
e19a021b
FC
784# [perl #97110]
785sub myrand(;$) { }
b5fb7ce3 786sub whatever($) { }
e19a021b 787my $a = myrand + 4 ;
b5fb7ce3 788my $b = whatever + 4 ;
e19a021b 789EXPECT
b5fb7ce3 790Warning: Use of "myrand" without parentheses is ambiguous at - line 4.
e19a021b 791########
0453d815 792# toke.c
e8ae98db
RGS
793use warnings "ambiguous";
794print for keys %+; # should not warn
795EXPECT
796########
7950e9cf 797# toke.c [This does not warn any more.]
0453d815
PM
798sub fred {};
799-fred ;
898c3bca
FC
800sub hank : lvalue {$_}
801--hank; # This should *not* warn [perl #77240]
0453d815 802EXPECT
0453d815 803########
7950e9cf 804# toke.c [This does not warn any more.]
0453d815
PM
805$^W = 0 ;
806sub fred {} ;
807-fred ;
808{
4438c4b7 809 no warnings 'ambiguous' ;
0453d815 810 -fred ;
4438c4b7 811 use warnings 'ambiguous' ;
0453d815
PM
812 -fred ;
813}
814-fred ;
815EXPECT
0453d815 816########
7950e9cf 817# toke.c [This does not warn any more.]
43b5ab4c
BF
818use utf8;
819use open qw( :utf8 :std );
820sub frèd {};
821-frèd ;
822EXPECT
43b5ab4c 823########
7950e9cf 824# toke.c [This does not warn any more.]
43b5ab4c
BF
825$^W = 0 ;
826use utf8;
827use open qw( :utf8 :std );
828sub frèd {} ;
829-frèd ;
830{
831 no warnings 'ambiguous' ;
832 -frèd ;
833 use warnings 'ambiguous' ;
834 -frèd ;
835}
836-frèd ;
837EXPECT
43b5ab4c 838########
7950e9cf 839# toke.c [This does not warn any more.]
43b5ab4c
BF
840use utf8;
841use open qw( :utf8 :std );
842sub ᒍᒘᒊ {};
843-ᒍᒘᒊ ;
844EXPECT
43b5ab4c 845########
7950e9cf 846# toke.c [This does not warn any more.]
43b5ab4c
BF
847$^W = 0 ;
848use utf8;
849use open qw( :utf8 :std );
850sub ᒍᒘᒊ {} ;
851-ᒍᒘᒊ ;
852{
853 no warnings 'ambiguous' ;
854 -ᒍᒘᒊ ;
855 use warnings 'ambiguous' ;
856 -ᒍᒘᒊ ;
857}
858-ᒍᒘᒊ ;
859EXPECT
43b5ab4c
BF
860########
861# toke.c
0453d815 862open FOO || time;
240d1b6f 863open local *FOO; # should be ok
0453d815
PM
864EXPECT
865Precedence problem: open FOO should be open(FOO) at - line 2.
866########
71aa9713
BF
867# toke.c
868use utf8;
869use open qw( :utf8 :std );
870open FÒÒ || time;
871EXPECT
872Precedence problem: open FÒÒ should be open(FÒÒ) at - line 4.
873########
874# toke.c
875use utf8;
876use open qw( :utf8 :std );
877open ᒍOO || time;
878EXPECT
879Precedence problem: open ᒍOO should be open(ᒍOO) at - line 4.
880########
66fbe8fb
HS
881# toke.c (and [perl #16184])
882open FOO => "<&0"; close FOO;
883EXPECT
884########
0453d815
PM
885# toke.c
886$^W = 0 ;
887open FOO || time;
888{
e476b1b5 889 no warnings 'precedence' ;
0453d815 890 open FOO || time;
e476b1b5 891 use warnings 'precedence' ;
0453d815
PM
892 open FOO || time;
893}
894open FOO || time;
db3abe52 895open Foo::BAR; # this should not warn
0453d815
PM
896EXPECT
897Precedence problem: open FOO should be open(FOO) at - line 3.
898Precedence problem: open FOO should be open(FOO) at - line 8.
899Precedence problem: open FOO should be open(FOO) at - line 10.
900########
901# toke.c
902$^W = 0 ;
71aa9713
BF
903use utf8;
904use open qw( :utf8 :std );
905open FÒÒ || time;
906{
907 no warnings 'precedence' ;
908 open FÒÒ || time;
909 use warnings 'precedence' ;
910 open FÒÒ || time;
911}
912open FÒÒ || time;
913EXPECT
914Precedence problem: open FÒÒ should be open(FÒÒ) at - line 5.
915Precedence problem: open FÒÒ should be open(FÒÒ) at - line 10.
916Precedence problem: open FÒÒ should be open(FÒÒ) at - line 12.
917########
918# toke.c
919use utf8;
920use open qw( :utf8 :std );
921$^W = 0 ;
922open ᒍÒÒ || time;
923{
924 no warnings 'precedence' ;
925 open ᒍÒÒ || time;
926 use warnings 'precedence' ;
927 open ᒍÒÒ || time;
928}
929open ᒍÒÒ || time;
930EXPECT
931Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 5.
932Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 10.
933Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 12.
934########
935# toke.c
936$^W = 0 ;
0453d815
PM
937*foo *foo ;
938{
4438c4b7 939 no warnings 'ambiguous' ;
0453d815 940 *foo *foo ;
4438c4b7 941 use warnings 'ambiguous' ;
0453d815
PM
942 *foo *foo ;
943}
944*foo *foo ;
9700e2d3
FC
945# These should not warn [perl #117535]:
946foo**foo ;
947no warnings 'deprecated';
948sort $*foo ;
949sort $ *foo ;
0453d815
PM
950EXPECT
951Operator or semicolon missing before *foo at - line 3.
952Ambiguous use of * resolved as operator * at - line 3.
953Operator or semicolon missing before *foo at - line 8.
954Ambiguous use of * resolved as operator * at - line 8.
955Operator or semicolon missing before *foo at - line 10.
956Ambiguous use of * resolved as operator * at - line 10.
767a6a26
PM
957########
958# toke.c
9700e2d3
FC
959$^W = 0 ;
960%foo %foo ;
961{
962 no warnings 'ambiguous' ;
963 %foo %foo ;
964 use warnings 'ambiguous' ;
965 %foo %foo ;
966}
967%foo %foo ;
968# This should not produce ambiguity warnings [perl #117535]:
969sort $%foo ;
970sort $ %foo ;
971EXPECT
972Operator or semicolon missing before %foo at - line 3.
973Ambiguous use of % resolved as operator % at - line 3.
974Operator or semicolon missing before %foo at - line 8.
975Ambiguous use of % resolved as operator % at - line 8.
976Operator or semicolon missing before %foo at - line 10.
977Ambiguous use of % resolved as operator % at - line 10.
978Bareword found where operator expected at - line 12, near "$%foo"
979 (Missing operator before foo?)
980Bareword found where operator expected at - line 13, near "$ %foo"
981 (Missing operator before foo?)
982Illegal modulus zero at - line 3.
983########
984# toke.c
985$^W = 0 ;
986&foo &foo ;
987{
988 no warnings 'ambiguous' ;
989 &foo &foo ;
990 use warnings 'ambiguous' ;
991 &foo &foo ;
992}
993&foo &foo ;
994# These should not warn produce ambiguity warnings [perl #76910]:
995foo&&foo ;
996sort $&foo ;
997sort $ &foo ;
998EXPECT
999Operator or semicolon missing before &foo at - line 3.
1000Ambiguous use of & resolved as operator & at - line 3.
1001Operator or semicolon missing before &foo at - line 8.
1002Ambiguous use of & resolved as operator & at - line 8.
1003Operator or semicolon missing before &foo at - line 10.
1004Ambiguous use of & resolved as operator & at - line 10.
1005Bareword found where operator expected at - line 13, near "$&foo"
1006 (Missing operator before foo?)
1007Bareword found where operator expected at - line 14, near "$ &foo"
1008 (Missing operator before foo?)
1009Undefined subroutine &main::foo called at - line 3.
1010########
1011# toke.c
02571fe8
BF
1012use utf8;
1013use open qw( :utf8 :std );
1014$^W = 0 ;
1015*foo *foo ;
1016{
1017 no warnings 'ambiguous' ;
1018 *foo *foo ;
1019 use warnings 'ambiguous' ;
1020 *foo *foo ;
1021}
1022*foo *foo ;
1023EXPECT
1024Operator or semicolon missing before *foo at - line 5.
1025Ambiguous use of * resolved as operator * at - line 5.
1026Operator or semicolon missing before *foo at - line 10.
1027Ambiguous use of * resolved as operator * at - line 10.
1028Operator or semicolon missing before *foo at - line 12.
1029Ambiguous use of * resolved as operator * at - line 12.
1030########
1031# toke.c
e476b1b5 1032use warnings 'misc' ;
767a6a26 1033my $a = "\m" ;
e476b1b5 1034no warnings 'misc' ;
767a6a26
PM
1035$a = "\m" ;
1036EXPECT
1037Unrecognized escape \m passed through at - line 3.
1038########
1039# toke.c
52ed07f6
BF
1040use warnings 'misc' ;
1041my $a = "abcd\E" ;
1042no warnings 'misc' ;
1043$a = "abcd\E" ;
1044EXPECT
820438b1 1045Useless use of \E at - line 3.
52ed07f6
BF
1046########
1047# toke.c
1c2511e0 1048use feature 'postderef_qq';
1f25714a
FC
1049(\$_)->$*;
1050"$_->$*";
1f25714a
FC
1051(\$_)->$*;
1052"$_->$*";
1053EXPECT
1f25714a
FC
1054########
1055# toke.c
767a6a26
PM
1056use warnings 'portable' ;
1057my $a = 0b011111111111111111111111111111110 ;
1058 $a = 0b011111111111111111111111111111111 ;
1059 $a = 0b111111111111111111111111111111111 ;
1060 $a = 0x0fffffffe ;
1061 $a = 0x0ffffffff ;
1062 $a = 0x1ffffffff ;
1063 $a = 0037777777776 ;
1064 $a = 0037777777777 ;
1065 $a = 0047777777777 ;
1066no warnings 'portable' ;
1067 $a = 0b011111111111111111111111111111110 ;
1068 $a = 0b011111111111111111111111111111111 ;
1069 $a = 0b111111111111111111111111111111111 ;
1070 $a = 0x0fffffffe ;
1071 $a = 0x0ffffffff ;
1072 $a = 0x1ffffffff ;
1073 $a = 0037777777776 ;
1074 $a = 0037777777777 ;
1075 $a = 0047777777777 ;
1076EXPECT
1077Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
1078Hexadecimal number > 0xffffffff non-portable at - line 8.
1079Octal number > 037777777777 non-portable at - line 11.
1080########
1081# toke.c
1082use warnings 'overflow' ;
1083my $a = 0b011111111111111111111111111111110 ;
1084 $a = 0b011111111111111111111111111111111 ;
15041a67 1085 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
1086 $a = 0x0fffffffe ;
1087 $a = 0x0ffffffff ;
15041a67 1088 $a = 0x10000000000000000 ;
767a6a26
PM
1089 $a = 0037777777776 ;
1090 $a = 0037777777777 ;
15041a67 1091 $a = 002000000000000000000000;
767a6a26
PM
1092no warnings 'overflow' ;
1093 $a = 0b011111111111111111111111111111110 ;
1094 $a = 0b011111111111111111111111111111111 ;
15041a67 1095 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26
PM
1096 $a = 0x0fffffffe ;
1097 $a = 0x0ffffffff ;
15041a67 1098 $a = 0x10000000000000000 ;
767a6a26
PM
1099 $a = 0037777777776 ;
1100 $a = 0037777777777 ;
15041a67 1101 $a = 002000000000000000000000;
767a6a26
PM
1102EXPECT
1103Integer overflow in binary number at - line 5.
1104Integer overflow in hexadecimal number at - line 8.
1105Integer overflow in octal number at - line 11.
8593bda5
GS
1106########
1107# toke.c
ac206dc8 1108BEGIN { $^C = 1; }
30b17cc1
A
1109dump;
1110CORE::dump;
1111EXPECT
1112dump() better written as CORE::dump(). dump() will no longer be available in Perl 5.30 at - line 3.
1113- syntax OK
1114########
1115# toke.c
1116BEGIN { $^C = 1; }
1117no warnings 'deprecated';
1118dump;
1119CORE::dump;
1120EXPECT
1121- syntax OK
1122########
1123# toke.c
1124BEGIN { $^C = 1; }
1125no warnings 'deprecated';
ac206dc8
RGS
1126use warnings 'misc';
1127dump;
1128CORE::dump;
1129EXPECT
30b17cc1 1130dump() better written as CORE::dump(). dump() will no longer be available in Perl 5.30 at - line 5.
ac206dc8
RGS
1131- syntax OK
1132########
1133# toke.c
1134use warnings 'misc';
1135use subs qw/dump/;
93f09d7b 1136sub dump { print "no warning for overridden dump\n"; }
ac206dc8
RGS
1137dump;
1138EXPECT
93f09d7b 1139no warning for overridden dump
ac206dc8
RGS
1140########
1141# toke.c
8593bda5
GS
1142use warnings 'ambiguous';
1143"@mjd_previously_unused_array";
1144no warnings 'ambiguous';
29fb1d0e 1145"@mjd_previously_unused_array2";
8593bda5
GS
1146EXPECT
1147Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.
707afd92
MS
1148########
1149# toke.c
29fb1d0e
BF
1150use utf8;
1151use open qw( :utf8 :std );
1152use warnings 'ambiguous';
1153"@mjd_previously_unused_àrray";
1154no warnings 'ambiguous';
1155"@mjd_previously_unused_àrray2";
1156EXPECT
1157Possible unintended interpolation of @mjd_previously_unused_àrray in string at - line 5.
1158########
1159# toke.c
1160use utf8;
1161use open qw( :utf8 :std );
1162use warnings 'ambiguous';
1163"@mjd_previously_unused_ぁrrぁy";
1164no warnings 'ambiguous';
1165"@mjd_previously_unused_ぁrrぁy2";
1166EXPECT
1167Possible unintended interpolation of @mjd_previously_unused_ぁrrぁy in string at - line 5.
1168########
10030f4b
FC
1169-w
1170# toke.c
1171$_ = "@DB::args";
1172EXPECT
1173########
29fb1d0e 1174# toke.c
d8c55666 1175# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
1176use warnings 'regexp';
1177"foo" =~ /foo/c;
64e578a2 1178"foo" =~ /foo/cg;
4ac733c9
MJD
1179no warnings 'regexp';
1180"foo" =~ /foo/c;
64e578a2 1181"foo" =~ /foo/cg;
4ac733c9
MJD
1182EXPECT
1183Use of /c modifier is meaningless without /g at - line 4.
1184########
1185# toke.c
d8c55666 1186# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
4ac733c9
MJD
1187use warnings 'regexp';
1188$_ = "ab" ;
1189s/ab/ab/c;
64e578a2 1190s/ab/ab/cg;
4ac733c9
MJD
1191no warnings 'regexp';
1192s/ab/ab/c;
64e578a2 1193s/ab/ab/cg;
4ac733c9 1194EXPECT
64e578a2
MJD
1195Use of /c modifier is meaningless in s/// at - line 5.
1196Use of /c modifier is meaningless in s/// at - line 6.
d8c55666
MJD
1197########
1198-wa
1199# toke.c
1200# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
1201print "@F\n";
1202EXPECT
1203
1204########
1205-w
1206# toke.c
1207# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
1208print "@F\n";
1209EXPECT
1210Possible unintended interpolation of @F in string at - line 4.
1211Name "main::F" used only once: possible typo at - line 4.
1212########
1213-wa
1214# toke.c
1215# 20020414 mjd-perl-patch+@plover.com
1216EXPECT
1217
2710853f
MJD
1218########
1219# toke.c
1220# 20020414 mjd-perl-patch+@plover.com
1221# In 5.7.3, this emitted "Possible unintended interpolation" warnings
1222use warnings 'ambiguous';
1223$s = "(@-)(@+)";
1224EXPECT
1225
56da5a46
RGS
1226########
1227# toke.c
1228# mandatory warning
1229eval q/if ($a) { } elseif ($b) { }/;
1230no warnings "syntax";
1231eval q/if ($a) { } elseif ($b) { }/;
1232EXPECT
1233elseif should be elsif at (eval 1) line 1.
1234########
1235# toke.c
1236# mandatory warning
1237eval q/5 6/;
1238no warnings "syntax";
1239eval q/5 6/;
1240EXPECT
1241Number found where operator expected at (eval 1) line 1, near "5 6"
1242 (Missing operator before 6?)
984200d0
YST
1243########
1244# toke.c
7fc874e8 1245use warnings "syntax"; no warnings "deprecated";
984200d0
YST
1246$_ = $a = 1;
1247$a !=~ /1/;
1248$a !=~ m#1#;
1249$a !=~/1/;
decca21c
YST
1250$a !=~ y/1//;
1251$a !=~ tr/1//;
1252$a !=~ s/1//;
984200d0
YST
1253$a != ~/1/;
1254no warnings "syntax";
1255$a !=~ /1/;
1256$a !=~ m#1#;
1257$a !=~/1/;
decca21c
YST
1258$a !=~ y/1//;
1259$a !=~ tr/1//;
1260$a !=~ s/1//;
984200d0
YST
1261EXPECT
1262!=~ should be !~ at - line 4.
1263!=~ should be !~ at - line 5.
1264!=~ should be !~ at - line 6.
1265!=~ should be !~ at - line 7.
decca21c
YST
1266!=~ should be !~ at - line 8.
1267!=~ should be !~ at - line 9.
1108974d
RGS
1268########
1269# toke.c
1270our $foo :unique;
8e5dadda
NC
1271sub pam :locked;
1272sub glipp :locked {
1273}
1274sub whack_eth ($) : locked {
1275}
d1d15184 1276no warnings 'deprecated';
1108974d 1277our $bar :unique;
8e5dadda
NC
1278sub zapeth :locked;
1279sub ker_plop :locked {
1280}
1281sub swa_a_p ($) : locked {
1282}
1108974d 1283EXPECT
c9680906
A
1284Attribute "unique" is deprecated, and will disappear in Perl 5.28 at - line 2.
1285Attribute "locked" is deprecated, and will disappear in Perl 5.28 at - line 3.
1286Attribute "locked" is deprecated, and will disappear in Perl 5.28 at - line 4.
1287Attribute "locked" is deprecated, and will disappear in Perl 5.28 at - line 6.
9e8d7757
RB
1288########
1289# toke.c
60e04ba1 1290use warnings "syntax";
9e8d7757
RB
1291sub proto_after_array(@$);
1292sub proto_after_arref(\@$);
1293sub proto_after_arref2(\[@$]);
1294sub proto_after_arref3(\[@$]_);
1295sub proto_after_hash(%$);
1296sub proto_after_hashref(\%$);
1297sub proto_after_hashref2(\[%$]);
1298sub underscore_last_pos($_);
1299sub underscore2($_;$);
1300sub underscore_fail($_$);
1301sub underscore_after_at(@_);
689aac7b
FC
1302our sub hour (@$);
1303my sub migh (@$);
e7d0b801 1304use feature 'state';
689aac7b
FC
1305state sub estate (@$);
1306package other;
1307sub hour (@$);
1308sub migh (@$);
1309sub estate (@$);
9e8d7757
RB
1310no warnings "syntax";
1311sub proto_after_array(@$);
1312sub proto_after_hash(%$);
1313sub underscore_fail($_$);
1314EXPECT
1315Prototype after '@' for main::proto_after_array : @$ at - line 3.
1316Prototype after '%' for main::proto_after_hash : %$ at - line 7.
aef2a98a 1317Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12.
9e8d7757 1318Prototype after '@' for main::underscore_after_at : @_ at - line 13.
689aac7b
FC
1319Prototype after '@' for hour : @$ at - line 14.
1320Prototype after '@' for migh : @$ at - line 15.
1321Prototype after '@' for estate : @$ at - line 17.
1322Prototype after '@' for hour : @$ at - line 19.
1323Prototype after '@' for migh : @$ at - line 20.
1324Prototype after '@' for estate : @$ at - line 21.
77772344
B
1325########
1326# toke.c
1327use warnings "ambiguous";
1328"foo\nn" =~ /^foo$\n/;
1329"foo\nn" =~ /^foo${\}n/;
1330my $foo = qr/^foo$\n/;
1331my $bar = qr/^foo${\}n/;
1332no warnings "ambiguous";
1333"foo\nn" =~ /^foo$\n/;
1334"foo\nn" =~ /^foo${\}n/;
1335my $foo = qr/^foo$\n/;
1336my $bar = qr/^foo${\}n/;
1337EXPECT
1338Possible unintended interpolation of $\ in regex at - line 3.
1339Possible unintended interpolation of $\ in regex at - line 5.
d83f38d8
NC
1340########
1341# toke.c
f0a2b745
KW
1342use warnings 'syntax' ;
1343my $a = "\o";
1344my $a = "\o{";
1345my $a = "\o{}";
1346no warnings 'syntax' ;
1347my $a = "\o";
1348my $a = "\o{";
1349my $a = "\o{}";
1350EXPECT
1351Missing braces on \o{} at - line 3, within string
1352Missing right brace on \o{ at - line 4, within string
1353Number with no digits at - line 5, within string
1354BEGIN not safe after errors--compilation aborted at - line 6.
1355########
1356# toke.c
1357use warnings 'digit' ;
1358my $a = "\o{1238456}";
1359no warnings 'digit' ;
1360my $a = "\o{1238456}";
1361EXPECT
1362Non-octal character '8'. Resolved as "\o{123}" at - line 3.
725a61d7
Z
1363########
1364# toke.c
1365use warnings;
c3383756 1366print ref ? "yes\n" : "no\n" foreach [], ''; # ? is unambiguosly an operator
725a61d7 1367EXPECT
725a61d7
Z
1368yes
1369no
c3383756
DIM
1370########
1371# toke .c
1372use warnings;
1373$a =~ ?rand?; # ? is not a regex match
1374EXPECT
1375syntax error at - line 3, near "=~ ?"
1376Execution of - aborted due to compilation errors.
17a3df4c
KW
1377########
1378# toke.c
46b78aa8
KW
1379BEGIN {
1380 if (ord('A') == 193) {
1381 print "SKIPPED\n# result varies depending on which ebcdic platform";
1382 exit 0;
1383 }
1384}
17a3df4c 1385use warnings;
17a3df4c
KW
1386$a = "\c,";
1387$a = "\c`";
bfdc8cd3 1388no warnings 'syntax', 'deprecated';
17a3df4c
KW
1389$a = "\c,";
1390$a = "\c`";
17a3df4c 1391EXPECT
bfdc8cd3
A
1392"\c," is more clearly written simply as "l". This will be a fatal error in Perl 5.28 at - line 9.
1393"\c`" is more clearly written simply as "\ ". This will be a fatal error in Perl 5.28 at - line 10.
421e43ba
KW
1394########
1395# toke.c
a27ed980
KW
1396BEGIN {
1397 if (ord('A') == 193) {
1398 print "SKIPPED\n# test is ASCII-specific";
1399 exit 0;
1400 }
1401}
1402use warnings;
1403my $a = "\c{ack}";
1404EXPECT
1405OPTION fatal
1406Use ";" instead of "\c{" at - line 9.
1407########
1408# toke.c
1409BEGIN {
1410 if (ord('A') == 65) {
1411 print "SKIPPED\n# test is EBCDIC-specific";
1412 exit 0;
1413 }
1414}
421e43ba
KW
1415use warnings;
1416my $a = "\c{ack}";
1417EXPECT
1418OPTION fatal
a27ed980 1419Sequence "\c{" invalid at - line 9.
3955e1a9
KW
1420########
1421# toke.c
9b8f4e92
KW
1422my $a = "\câ";
1423EXPECT
1424OPTION fatal
1425Character following "\c" must be printable ASCII at - line 2.
1426########
1427# toke.c
3955e1a9
KW
1428use warnings 'syntax' ;
1429my $a = qr/foo/du;
ff3f26d2 1430$a = qr/foo/lai;
3955e1a9 1431$a = qr/foo/lil;
ff3f26d2
KW
1432$a = qr/foo/aia;
1433$a = qr/foo/aaia;
3955e1a9
KW
1434no warnings 'syntax' ;
1435my $a = qr/foo/du;
1436EXPECT
1437Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= "
1438Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= "
1439Regexp modifier "/l" may not appear twice at - line 5, near "= "
ff3f26d2
KW
1440Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= "
1441BEGIN not safe after errors--compilation aborted at - line 8.
ba05d9aa
FC
1442########
1443# toke.c
1444# [perl #4362]
1445eval "print q\xabfoo";
1446print "ok\n" if
1447 $@ =~ /Can't find string terminator "\xab" anywhere before EOF/;
1448EXPECT
1449ok
5c66c3dd
BF
1450########
1451# toke.c
1452use utf8;
1453use open qw( :utf8 :std );
1454use warnings 'ambiguous' ;
1455sub frèd {}
1456$a = ${frèd} ;
1457no warnings 'ambiguous' ;
1458$a = ${frèd} ;
1459EXPECT
1460Ambiguous use of ${frèd} resolved to $frèd at - line 6.
1461########
1462# toke.c
1463use utf8;
1464use open qw( :utf8 :std );
1465use warnings 'ambiguous' ;
1466sub f렏 {}
1467$a = ${f렏} ;
1468no warnings 'ambiguous' ;
1469$a = ${f렏} ;
1470EXPECT
1471Ambiguous use of ${f렏} resolved to $f렏 at - line 6.
3773592b
BF
1472########
1473# toke.c
1474use utf8;
1475use open qw( :utf8 :std );
1476use warnings;
1477CORE::렏;
1478EXPECT
1479CORE::렏 is not a keyword at - line 5.
5dc13276
MH
1480########
1481# toke.c
1482# [perl #16249]
1483print '';
1484eval this_method_is_fake ();
1485EXPECT
1486Undefined subroutine &main::this_method_is_fake called at - line 4.
a71a1afb
FC
1487########
1488# toke.c
1489# [perl #107002] Erroneous ambiguity warnings
1490sub { # do not actually call require
1491 require a::b . 1; # These used to produce erroneous
1492 require a::b + 1; # ambiguity warnings.
1493}
1494EXPECT
4d68ffa0
KW
1495########
1496# toke.c
412f55bb
KW
1497# [perl #113094], [perl #119101], since reverted so no warnings generated
1498use warnings;
003a6439
CB
1499print "aa" =~ m{^a\{1,2\}$}, "A\n";
1500print "aa" =~ m{^a\x\{61\}$}, "B\n";
1501print "a\\x{6F}" =~ m{^a\\x\{6F\}$}, "C\n";
1502print "a\\o" =~ m{^a\\\x\{6F\}$}, "D\n";
1503print "a\\\\x{6F}" =~ m{^a\\\\x\{6F\}$}, "E\n";
1504print "a\\\\o" =~ m{^a\\\\\x\{6F\}$}, "F\n";
1505print "aa" =~ m{^a{1,2}$}, "G\n";
1506print "aq" =~ m[^a\[a-z\]$], "H\n";
1507print "aq" =~ m(^a\(q\)$), "I\n";
4d68ffa0 1508EXPECT
412f55bb 1509Illegal hexadecimal digit '\' ignored at - line 5.
412f55bb
KW
1510Illegal hexadecimal digit '\' ignored at - line 7.
1511Illegal hexadecimal digit '\' ignored at - line 9.
003a6439
CB
1512A
1513B
15141C
1515D
15161E
1517F
15181G
1519H
1520I
b29f65fc
BF
1521########
1522# toke.c
1523#[perl #119123] disallow literal control character variables
b29f65fc
BF
1524*{
1525 Foo
1526}; # shouldn't warn on {\n, even though \n is a control character
1527EXPECT
46879fad
DM
1528########
1529# toke.c
1530# [perl #120288] -X at start of line gave spurious warning, where X is not
1531# a filetest operator
1532-a;
1533;-a;
1534EXPECT
b3089e96
AV
1535########
1536# toke.c
1537# [perl #124113] Compile-time warning with UTF8 variable in array index
1538use warnings;
1539use utf8;
1540my $𝛃 = 0;
1541my @array = (0);
1542my $v = $array[ 0 + $𝛃 ];
1543 $v = $array[ $𝛃 + 0 ];
1544EXPECT
6e59c862
AV
1545########
1546# toke.c
1547# Allow Unicode here doc boundaries
1548use warnings;
1549use utf8;
1550my $v = <<EnFraçais;
1551Comme ca!
1552EnFraçais
1553print $v;
1554EXPECT
1555Comme ca!
8ce2ba82
AV
1556########
1557# toke.c
1558# Fix 'Use of "..." without parentheses is ambiguous' warning for
b59c097b
AV
1559# Unicode function names. If not under PERL_UNICODE, this will generate
1560# a "Wide character" warning
8ce2ba82
AV
1561use utf8;
1562use warnings;
1563sub 𝛃(;$) { return 0; }
1564my $v = 𝛃 - 5;
1565EXPECT
b59c097b
AV
1566OPTION regex
1567(Wide character.*\n)?Warning: Use of "𝛃" without parentheses is ambiguous
554b0b9d
DC
1568########
1569# RT #4346 Case 1: Warnings for print (...)
1570# TODO RT #4346: Warnings for print(...) are inconsistent
1571use warnings;
1572print ("((\n");
1573print (">>\n");
1574EXPECT
1575print (...) interpreted as function at - line 3.
1576print (...) interpreted as function at - line 4.
1577((
1578>>
1579########
1580# RT #4346 Case 2: Warnings for print (...)
1581use warnings;
1582print ("((\n");
1583print (">>\n")
1584EXPECT
1585print (...) interpreted as function at - line 3.
1586print (...) interpreted as function at - line 4.
1587((
1588>>
1589########
1590# RT #4346 Case 3: Warnings for print (...)
1591# TODO RT #4346: Warnings for print(...) are inconsistent
1592use warnings;
1593print (">>\n");
1594print ("((\n");
1595EXPECT
1596print (...) interpreted as function at - line 3.
1597print (...) interpreted as function at - line 4.
1598>>
1599((
1600########
1601# RT #4346 Case 4: Warnings for print (...)
1602# TODO RT #4346: Warnings for print(...) are inconsistent
1603use warnings;
1604print (")\n");
1605print ("))\n");
1606EXPECT
1607print (...) interpreted as function at - line 3.
1608print (...) interpreted as function at - line 4.
1609)
1610))
94749a5e
KW
1611########
1612# NAME Non-grapheme delimiters
1613BEGIN{
1614 if (ord('A') == 193) {
1615 print "SKIPPED\n# ebcdic platforms generates different Malformed UTF-8 warnings.";
1616 exit 0;
1617 }
1618}
1619use utf8;
1620my $a = qr ̂foobar̂;
1621EXPECT
7cb258c1 1622Use of unassigned code point or non-standalone grapheme for a delimiter will be a fatal error starting in Perl 5.30 at - line 8.
21921336
KW
1623########
1624# NAME [perl $130567] Assertion failure
1625BEGIN {
1626 if (ord('A') != 65) {
1627 print "SKIPPED\n# test is ASCII-specific";
1628 exit 0;
1629 }
1630}
1631no warnings "uninitialized";
1632$_= "";
1633s//\3000/;
1634s//"\x{180};;s\221(*$@$`\241\275";/gee;
1635s//"s\221\302\302\302\302\302\302\302$@\241\275";/gee;
1636EXPECT
1637OPTION fatal
1638Malformed UTF-8 character: \xc3\x20 (unexpected non-continuation byte 0x20, immediately after start byte 0xc3; need 2 bytes, got 1) in eval "string" at - line 11.
1639Malformed UTF-8 character (fatal) at - line 11.