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