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