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