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
1 toke.c  AOK
2
3     we seem to have lost a few ambiguous warnings!!
4
5      Prototype after '@' for main::foo
6         sub foo (@$)
7
8      Illegal character in prototype for main::foo
9         sub foo (x)
10
11      \1 better written as $1 
12         use warnings 'syntax' ;
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
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
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
52      %s (...) interpreted as function 
53         print ("")
54         printf ("")
55         sort ("")
56
57      Old package separator used in string
58         "$foo'bar"
59         "@foo'bar"
60         "$#foo'bar"
61
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
82     Unrecognized escape \\%c passed through
83         $a = "\m" ;
84
85     Useless use of \\E.
86         $a = "abcd\E" ;
87
88     Postfix dereference is experimental
89
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 ;
111
112     Use of /c modifier is meaningless without /g     
113
114     Use of /c modifier is meaningless in s///
115
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
131 __END__
132 use utf8;
133 use open qw( :utf8 :std );
134 use warnings;
135 eval "sub fòò (@\$\0) {}";
136 EXPECT
137 Prototype after '@' for main::fòò : @$\0 at (eval 1) line 1.
138 Illegal character in prototype for main::fòò : @$\0 at (eval 1) line 1.
139 ########
140 use utf8;
141 use open qw( :utf8 :std );
142 use warnings;
143 eval "sub foo (@\0) {}";
144 eval "sub foo2 :prototype(@\0) {}";
145 EXPECT
146 Prototype after '@' for main::foo : @\0 at (eval 1) line 1.
147 Illegal character in prototype for main::foo : @\0 at (eval 1) line 1.
148 Prototype after '@' for main::foo2 : @\x{0} at (eval 2) line 1.
149 Illegal character in prototype for main::foo2 : @\x{0} at (eval 2) line 1.
150 ########
151 BEGIN {
152     if (ord('A') == 193) {
153         print "SKIPPED\n# Different results on EBCDIC";
154         exit 0;
155     }
156 }
157 use utf8;
158 use open qw( :utf8 :std );
159 use warnings;
160 BEGIN { $::{"foo"} = "\@\$\0L\351on" }
161 BEGIN { eval "sub foo (@\$\0L\x{c3}\x{a9}on) {}"; }
162 EXPECT
163 Prototype after '@' for main::foo : @$\x{0}L... at (eval 1) line 1.
164 Illegal character in prototype for main::foo : @$\x{0}L... at (eval 1) line 1.
165 ########
166 use utf8;
167 use open qw( :utf8 :std );
168 use warnings;
169 BEGIN { eval "sub foo (@\0) {}"; }
170 EXPECT
171 Prototype after '@' for main::foo : @\0 at (eval 1) line 1.
172 Illegal character in prototype for main::foo : @\0 at (eval 1) line 1.
173 ########
174 use warnings;
175 eval "sub foo (@\xAB) {}";
176 EXPECT
177 Prototype after '@' for main::foo : @\x{ab} at (eval 1) line 1.
178 Illegal character in prototype for main::foo : @\x{ab} at (eval 1) line 1.
179 ########
180 use utf8;
181 use open qw( :utf8 :std );
182 use warnings;
183 BEGIN { eval "sub foo (@\x{30cb}) {}"; }
184 EXPECT
185 Prototype after '@' for main::foo : @\x{30cb} at (eval 1) line 1.
186 Illegal character in prototype for main::foo : @\x{30cb} at (eval 1) line 1.
187 ########
188 use warnings;
189 sub f ([);
190 sub f :prototype([)
191 EXPECT
192 Missing ']' in prototype for main::f : [ at - line 2.
193 Missing ']' in prototype for main::f : [ at - line 3.
194 ########
195 use warnings;
196 package bar { sub bar { eval q"sub foo ([)" } }
197 bar::bar
198 EXPECT
199 Missing ']' in prototype for bar::foo : [ at (eval 1) line 1.
200 ########
201 # toke.c
202 $a =~ m/$foo/eq;
203 $a =~ s/$foo/fool/seq;
204
205 EXPECT
206 OPTION fatal
207 Unknown regexp modifier "/e" at - line 2, near "=~ "
208 Unknown regexp modifier "/q" at - line 2, near "=~ "
209 Unknown regexp modifier "/q" at - line 3, near "=~ "
210 Execution of - aborted due to compilation errors.
211 ########
212 # toke.c
213 use utf8;
214 use open qw( :utf8 :std );
215 $a =~ m/$foo/eネq;
216 $a =~ s/$foo/fool/seネq;
217
218 EXPECT
219 OPTION fatal
220 Unknown regexp modifier "/e" at - line 4, near "=~ "
221 Unknown regexp modifier "/ネ" at - line 4, near "=~ "
222 Unknown regexp modifier "/q" at - line 4, near "=~ "
223 Unknown regexp modifier "/ネ" at - line 5, near "=~ "
224 Unknown regexp modifier "/q" at - line 5, near "=~ "
225 Execution of - aborted due to compilation errors.
226 ########
227 # toke.c
228 use warnings 'syntax' ;
229 s/(abc)/\1/;
230 no warnings 'syntax' ;
231 s/(abc)/\1/;
232 EXPECT
233 \1 better written as $1 at - line 3.
234 ########
235 # toke.c
236 use warnings 'semicolon' ;
237 $a = 1
238 &time ;
239 no warnings 'semicolon' ;
240 $a = 1
241 &time ;
242 EXPECT
243 Semicolon seems to be missing at - line 3.
244 ########
245 # toke.c
246 use warnings 'syntax' ;
247 my $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 ;
257 EXPECT
258 Reversed += operator at - line 3.
259 Reversed -= operator at - line 4.
260 Reversed *= operator at - line 5.
261 Reversed %= operator at - line 6.
262 Reversed &= operator at - line 7.
263 Reversed .= operator at - line 8.
264 Reversed ^= operator at - line 9.
265 Reversed |= operator at - line 10.
266 Reversed <= operator at - line 11.
267 syntax error at - line 8, near "=."
268 syntax error at - line 9, near "=^"
269 syntax error at - line 10, near "=|"
270 Unterminated <> operator at - line 11.
271 ########
272 # toke.c
273 no warnings 'syntax' ;
274 my $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 ;
284 EXPECT
285 syntax error at - line 8, near "=."
286 syntax error at - line 9, near "=^"
287 syntax error at - line 10, near "=|"
288 Unterminated <> operator at - line 11.
289 ########
290 # toke.c
291 use warnings 'syntax' ;
292 my $a = $a[1,2] ;
293 no warnings 'syntax' ;
294 my $a = $a[1,2] ;
295 EXPECT
296 Multidimensional syntax $a[1,2] not supported at - line 3.
297 ########
298 # toke.c
299 use warnings 'syntax' ;
300 sub fred {} ; $SIG{TERM} = fred;
301 no warnings 'syntax' ;
302 $SIG{TERM} = fred;
303 EXPECT
304 You need to quote "fred" at - line 3.
305 ########
306 # toke.c
307 use utf8;
308 use open qw( :utf8 :std );
309 use warnings 'syntax' ;
310 sub frèd {} ; $SIG{TERM} = frèd;
311 no warnings 'syntax' ;
312 $SIG{TERM} = frèd;
313 EXPECT
314 You need to quote "frèd" at - line 5.
315 ########
316 # toke.c
317 use utf8;
318 use open qw( :utf8 :std );
319 use warnings 'syntax' ;
320 sub ふれど {} ; $SIG{TERM} = ふれど;
321 no warnings 'syntax' ;
322 $SIG{TERM} = ふれど;
323 EXPECT
324 You need to quote "ふれど" at - line 5.
325 ########
326 # toke.c
327 use warnings 'syntax' ;
328 $_ = "ab" ; 
329 s/(ab)/\1/e;
330 s//\(2)/e; # should be exempt
331 s/${\2}//; # same here
332 ()="${\2}"; # metoo
333 no warnings 'syntax' ;
334 $_ = "ab" ; 
335 s/(ab)/\1/e;
336 EXPECT
337 Can't use \1 to mean $1 in expression at - line 4.
338 ########
339 # toke.c
340 use warnings 'reserved' ;
341 $a = abc;
342 $a = { def
343
344 => 1 };
345 no warnings 'reserved' ;
346 $a = abc;
347 EXPECT
348 Unquoted string "abc" may clash with future reserved word at - line 3.
349 ########
350 # toke.c
351 use warnings 'qw' ;
352 @a = qw(a, b, c) ;
353 no warnings 'qw' ;
354 @a = qw(a, b, c) ;
355 EXPECT
356 Possible attempt to separate words with commas at - line 3.
357 ########
358 # toke.c
359 use warnings 'qw' ;
360 @a = qw(a b c # #) ;
361 no warnings 'qw' ;
362 @a = qw(a b c # #) ;
363 EXPECT
364 Possible attempt to put comments in qw() list at - line 3.
365 ########
366 # toke.c
367 use warnings 'qw' ;
368 @a = qw(a, b, c # #) ;
369 no warnings 'qw' ;
370 @a = qw(a, b, c # #) ;
371 EXPECT
372 Possible attempt to separate words with commas at - line 3.
373 Possible attempt to put comments in qw() list at - line 3.
374 ########
375 # toke.c
376 use warnings 'syntax' ;
377 print ("");
378 print ("") and $x = 1;
379 print ("") or die;
380 print ("") // die;
381 print (1+2) * 3 if 0; # only this one should warn
382 print (1+2) if 0;
383 EXPECT
384 print (...) interpreted as function at - line 7.
385 ########
386 # toke.c
387 no warnings 'syntax' ;
388 print ("")
389 EXPECT
390
391 ########
392 # toke.c
393 use warnings 'syntax' ;
394 printf ("");
395 printf ("") . '';
396 EXPECT
397 printf (...) interpreted as function at - line 4.
398 ########
399 # toke.c
400 no warnings 'syntax' ;
401 printf ("")
402 EXPECT
403
404 ########
405 # toke.c
406 use warnings 'syntax' ;
407 sort ("");
408 sort ("") . '';
409 EXPECT
410 sort (...) interpreted as function at - line 4.
411 ########
412 # toke.c
413 no warnings 'syntax' ;
414 sort ("")
415 EXPECT
416
417 ########
418 use warnings 'syntax';
419 @foo::bar = 1..3;
420 () = "$foo'bar";
421 () = "@foo'bar";
422 () = "$#foo'bar";
423 no warnings 'syntax' ;
424 () = "$foo'bar";
425 () = "@foo'bar";
426 () = "$#foo'bar";
427 EXPECT
428 Old package separator used in string at - line 3.
429         (Did you mean "$foo\'bar" instead?)
430 Old package separator used in string at - line 4.
431         (Did you mean "@foo\'bar" instead?)
432 Old package separator used in string at - line 5.
433         (Did you mean "$#foo\'bar" instead?)
434 ########
435 use warnings 'syntax'; use utf8;
436 @fooл::barл = 1..3;
437 () = "$fooл'barл";
438 () = "@fooл'barл";
439 () = "$#fooл'barл";
440 no warnings 'syntax' ;
441 () = "$fooл'barл";
442 () = "@fooл'barл";
443 () = "$#fooл'barл";
444 EXPECT
445 Old package separator used in string at - line 3.
446         (Did you mean "$fooл\'barл" instead?)
447 Old package separator used in string at - line 4.
448         (Did you mean "@fooл\'barл" instead?)
449 Old package separator used in string at - line 5.
450         (Did you mean "$#fooл\'barл" instead?)
451 ########
452 # toke.c
453 use warnings 'ambiguous' ;
454 $a = ${time[2]};
455 no warnings 'ambiguous' ;
456 $a = ${time[2]};
457 EXPECT
458 Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
459 ########
460 # toke.c
461 use warnings 'ambiguous' ;
462 $a = ${time{2}};
463 EXPECT
464 Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
465 ########
466 # toke.c
467 use warnings 'ambiguous' ;
468 $a = ${
469
470     time
471         {2}
472 };
473 warn "after";
474 EXPECT
475 Ambiguous use of ${time{...}} resolved to $time{...} at - line 5.
476 after at - line 8.
477 ########
478 # toke.c
479 use warnings 'ambiguous' ;
480 $a = ${
481
482 time[2]
483
484 };
485 $a = ${
486
487 time    
488    [2]
489
490 };
491 warn "after";
492 EXPECT
493 Ambiguous use of ${time[...]} resolved to $time[...] at - line 5.
494 Ambiguous use of ${time[...]} resolved to $time[...] at - line 10.
495 after at - line 14.
496 ########
497 # toke.c
498 no warnings 'ambiguous' ;
499 $a = ${time{2}};
500 EXPECT
501
502 ########
503 # toke.c
504 use warnings 'ambiguous' ;
505 $a = ${time} ;
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
511 no warnings 'ambiguous' ;
512 $a = ${time} ;
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
518 EXPECT
519 Ambiguous use of ${time} resolved to $time at - line 3.
520 Ambiguous use of @{time} resolved to @time at - line 4.
521 Ambiguous use of @{time} resolved to @time at - line 5.
522 Ambiguous use of %{time} resolved to %time at - line 6.
523 Ambiguous use of *{time} resolved to *time at - line 7.
524 Ambiguous use of &{time} resolved to &time at - line 8.
525 ########
526 # toke.c
527 use warnings 'ambiguous' ;
528 $a = ${
529 time
530 } ;
531 $a = @{
532 time
533 } ;
534 $a = $#{
535 time
536 } ;
537 $a = %{
538 time
539 } ;
540 $a = *{
541 time
542 } ;
543 $a = defined &{
544 time
545
546
547 } ;
548 warn "last";
549 EXPECT
550 Ambiguous use of ${time} resolved to $time at - line 4.
551 Ambiguous use of @{time} resolved to @time at - line 7.
552 Ambiguous use of @{time} resolved to @time at - line 10.
553 Ambiguous use of %{time} resolved to %time at - line 13.
554 Ambiguous use of *{time} resolved to *time at - line 16.
555 Ambiguous use of &{time} resolved to &time at - line 19.
556 last at - line 23.
557 ########
558 # toke.c
559 use warnings 'ambiguous' ;
560 sub fred {}
561 $a = ${fred} ;
562 no warnings 'ambiguous' ;
563 $a = ${fred} ;
564 EXPECT
565 Ambiguous use of ${fred} resolved to $fred at - line 4.
566 ########
567 # toke.c
568 use warnings 'syntax' ;
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
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
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
606 $a = 1__23; print "$a\n";               # 40
607 $a = 12.3__4; print "$a\n";             # 41
608 $a = 12.34e1__2; printf("%.0f\n", $a);  # 42
609 no warnings 'syntax' ;
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";
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);
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";
647 $a = 1__23; print "$a\n";
648 $a = 12.3__4; print "$a\n";
649 $a = 12.34e1__2; printf("%.0f\n", $a);
650 EXPECT
651 OPTIONS regex
652 Misplaced _ in number at - line 6.
653 Misplaced _ in number at - line 11.
654 Misplaced _ in number at - line 16.
655 Misplaced _ in number at - line 17.
656 Misplaced _ in number at - line 20.
657 Misplaced _ in number at - line 21.
658 Misplaced _ in number at - line 24.
659 Misplaced _ in number at - line 25.
660 Misplaced _ in number at - line 28.
661 Misplaced _ in number at - line 29.
662 Misplaced _ in number at - line 31.
663 Misplaced _ in number at - line 32.
664 Misplaced _ in number at - line 33.
665 Misplaced _ in number at - line 35.
666 Misplaced _ in number at - line 36.
667 Misplaced _ in number at - line 37.
668 Misplaced _ in number at - line 39.
669 Misplaced _ in number at - line 40.
670 Misplaced _ in number at - line 41.
671 Misplaced _ in number at - line 42.
672 _123
673 123
674 123
675 123
676 123
677 _123
678 123
679 123
680 123
681 -123
682 -_123
683 -123
684 -123
685 -123
686 123.456
687 123.456
688 123.456
689 123.456
690 123.456
691 123.456
692 123.456
693 123.456
694 -123.456
695 -123.456
696 -123.456
697 -123.456
698 123456000000000
699 123456000000000
700 123456000000000
701 123456000000000
702 123456000000000
703 123456000000000
704 123456000000000
705 1.23456e-0?10
706 1.23456e-0?10
707 1.23456e-0?10
708 1.23456e-0?10
709 123
710 12.34
711 12340000000000
712 _123
713 123
714 123
715 123
716 123
717 _123
718 123
719 123
720 123
721 -123
722 -_123
723 -123
724 -123
725 -123
726 123.456
727 123.456
728 123.456
729 123.456
730 123.456
731 123.456
732 123.456
733 123.456
734 -123.456
735 -123.456
736 -123.456
737 -123.456
738 123456000000000
739 123456000000000
740 123456000000000
741 123456000000000
742 123456000000000
743 123456000000000
744 123456000000000
745 1.23456e-0?10
746 1.23456e-0?10
747 1.23456e-0?10
748 1.23456e-0?10
749 123
750 12.34
751 12340000000000
752 ########
753 # toke.c
754 use 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";
763 EXPECT
764 Misplaced _ in number at - line 3.
765 Misplaced _ in number at - line 4.
766 Misplaced _ in number at - line 5.
767 Misplaced _ in number at - line 6.
768 Misplaced _ in number at - line 7.
769 Misplaced _ in number at - line 8.
770 Misplaced _ in number at - line 9.
771 Misplaced _ in number at - line 10.
772 1
773 1
774 0
775 1
776 0
777 1.2
778 1.2
779 1
780 ########
781 # toke.c
782 use warnings 'bareword' ;
783 #line 25 "bar"
784 $a = FRED:: ;
785 no warnings 'bareword' ;
786 #line 25 "bar"
787 $a = FRED:: ;
788 EXPECT
789 Bareword "FRED::" refers to nonexistent package at bar line 25.
790 ########
791 # toke.c
792 use utf8;
793 use open qw( :utf8 :std );
794 use warnings 'bareword' ;
795 #line 25 "bar"
796 $a = FRÈD:: ;
797 no warnings 'bareword' ;
798 #line 25 "bar"
799 $a = FRÈD:: ;
800 EXPECT
801 Bareword "FRÈD::" refers to nonexistent package at bar line 25.
802 ########
803 # toke.c
804 use utf8;
805 use open qw( :utf8 :std );
806 use warnings 'bareword' ;
807 #line 25 "bar"
808 $a = ϞϞϞ:: ;
809 no warnings 'bareword' ;
810 #line 25 "bar"
811 $a = ϞϞϞ:: ;
812 EXPECT
813 Bareword "ϞϞϞ::" refers to nonexistent package at bar line 25.
814 ########
815 # toke.c
816 use warnings 'ambiguous' ;
817 sub time {}
818 my $a = time() ;
819 no warnings 'ambiguous' ;
820 my $b = time() ;
821 EXPECT
822 Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
823 ########
824 # toke.c
825 use warnings ;
826 eval <<'EOE';
827 #  line 30 "foo"
828 warn "yelp";
829 {
830   $_ = " \x{123} " ;
831 }
832 EOE
833 EXPECT
834 yelp at foo line 30.
835 ########
836 # toke.c
837 my $a = rand + 4 ;
838 $a = rand *^H ;
839 $a = rand $^H ;
840 EXPECT
841 Warning: Use of "rand" without parentheses is ambiguous at - line 2.
842 ########
843 # toke.c
844 $^W = 0 ;
845 my $a = rand + 4 ;
846 {
847     no warnings 'ambiguous' ;
848     $a = rand + 4 ;
849     use warnings 'ambiguous' ;
850     $a = rand + 4 ;
851 }
852 $a = rand + 4 ;
853 EXPECT
854 Warning: Use of "rand" without parentheses is ambiguous at - line 3.
855 Warning: Use of "rand" without parentheses is ambiguous at - line 8.
856 Warning: Use of "rand" without parentheses is ambiguous at - line 10.
857 ########
858 # [perl #97110]
859 sub myrand(;$) { }
860 sub whatever($) { }
861 my $a = myrand + 4 ;
862 my $b = whatever + 4 ;
863 EXPECT
864 Warning: Use of "myrand" without parentheses is ambiguous at - line 4.
865 ########
866 # toke.c
867 use warnings "ambiguous";
868 print for keys %+; # should not warn
869 EXPECT
870 ########
871 # toke.c [This does not warn any more.]
872 sub fred {};
873 -fred ;
874 sub hank : lvalue {$_}
875 --hank; # This should *not* warn [perl #77240]
876 EXPECT
877 ########
878 # toke.c [This does not warn any more.]
879 $^W = 0 ;
880 sub fred {} ;
881 -fred ;
882 {
883     no warnings 'ambiguous' ;
884     -fred ;
885     use warnings 'ambiguous' ;
886     -fred ;
887 }
888 -fred ;
889 EXPECT
890 ########
891 # toke.c [This does not warn any more.]
892 use utf8;
893 use open qw( :utf8 :std );
894 sub frèd {};
895 -frèd ;
896 EXPECT
897 ########
898 # toke.c [This does not warn any more.]
899 $^W = 0 ;
900 use utf8;
901 use open qw( :utf8 :std );
902 sub frèd {} ;
903 -frèd ;
904 {
905     no warnings 'ambiguous' ;
906     -frèd ;
907     use warnings 'ambiguous' ;
908     -frèd ;
909 }
910 -frèd ;
911 EXPECT
912 ########
913 # toke.c [This does not warn any more.]
914 use utf8;
915 use open qw( :utf8 :std );
916 sub ᒍᒘᒊ {};
917 -ᒍᒘᒊ ;
918 EXPECT
919 ########
920 # toke.c [This does not warn any more.]
921 $^W = 0 ;
922 use utf8;
923 use open qw( :utf8 :std );
924 sub ᒍᒘᒊ {} ;
925 -ᒍᒘᒊ ;
926 {
927     no warnings 'ambiguous' ;
928     -ᒍᒘᒊ ;
929     use warnings 'ambiguous' ;
930     -ᒍᒘᒊ ;
931 }
932 -ᒍᒘᒊ ;
933 EXPECT
934 ########
935 # toke.c
936 open FOO || time;
937 open local *FOO; # should be ok
938 EXPECT
939 Precedence problem: open FOO should be open(FOO) at - line 2.
940 ########
941 # toke.c
942 use utf8;
943 use open qw( :utf8 :std );
944 open FÒÒ || time;
945 EXPECT
946 Precedence problem: open FÒÒ should be open(FÒÒ) at - line 4.
947 ########
948 # toke.c
949 use utf8;
950 use open qw( :utf8 :std );
951 open ᒍOO || time;
952 EXPECT
953 Precedence problem: open ᒍOO should be open(ᒍOO) at - line 4.
954 ########
955 # toke.c (and [perl #16184])
956 open FOO => "<&0"; close FOO;
957 EXPECT
958 ########
959 # toke.c
960 $^W = 0 ;
961 open FOO || time;
962 {
963     no warnings 'precedence' ;
964     open FOO || time;
965     use warnings 'precedence' ;
966     open FOO || time;
967 }
968 open FOO || time;
969 open Foo::BAR; # this should not warn
970 EXPECT
971 Precedence problem: open FOO should be open(FOO) at - line 3.
972 Precedence problem: open FOO should be open(FOO) at - line 8.
973 Precedence problem: open FOO should be open(FOO) at - line 10.
974 ########
975 # toke.c
976 $^W = 0 ;
977 use utf8;
978 use open qw( :utf8 :std );
979 open FÒÒ || time;
980 {
981     no warnings 'precedence' ;
982     open FÒÒ || time;
983     use warnings 'precedence' ;
984     open FÒÒ || time;
985 }
986 open FÒÒ || time;
987 EXPECT
988 Precedence problem: open FÒÒ should be open(FÒÒ) at - line 5.
989 Precedence problem: open FÒÒ should be open(FÒÒ) at - line 10.
990 Precedence problem: open FÒÒ should be open(FÒÒ) at - line 12.
991 ########
992 # toke.c
993 use utf8;
994 use open qw( :utf8 :std );
995 $^W = 0 ;
996 open ᒍÒÒ || time;
997 {
998     no warnings 'precedence' ;
999     open ᒍÒÒ || time;
1000     use warnings 'precedence' ;
1001     open ᒍÒÒ || time;
1002 }
1003 open ᒍÒÒ || time;
1004 EXPECT
1005 Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 5.
1006 Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 10.
1007 Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 12.
1008 ########
1009 # toke.c
1010 $^W = 0 ;
1011 *foo *foo ;
1012 {
1013     no warnings 'ambiguous' ;
1014     *foo *foo ;
1015     use warnings 'ambiguous' ;
1016     *foo *foo ;
1017 }
1018 *foo *foo ;
1019 # These should not warn [perl #117535]:
1020 foo**foo ;
1021 no warnings 'deprecated';
1022 sort $*foo ;
1023 sort $ *foo ;
1024 EXPECT
1025 Operator or semicolon missing before *foo at - line 3.
1026 Ambiguous use of * resolved as operator * at - line 3.
1027 Operator or semicolon missing before *foo at - line 8.
1028 Ambiguous use of * resolved as operator * at - line 8.
1029 Operator or semicolon missing before *foo at - line 10.
1030 Ambiguous use of * resolved as operator * at - line 10.
1031 $* is no longer supported as of Perl 5.30 at - line 14.
1032 ########
1033 # toke.c
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]:
1044 sort $%foo ;
1045 sort $ %foo ;
1046 EXPECT
1047 Operator or semicolon missing before %foo at - line 3.
1048 Ambiguous use of % resolved as operator % at - line 3.
1049 Operator or semicolon missing before %foo at - line 8.
1050 Ambiguous use of % resolved as operator % at - line 8.
1051 Operator or semicolon missing before %foo at - line 10.
1052 Ambiguous use of % resolved as operator % at - line 10.
1053 Bareword found where operator expected at - line 12, near "$%foo"
1054         (Missing operator before foo?)
1055 Bareword found where operator expected at - line 13, near "$ %foo"
1056         (Missing operator before foo?)
1057 Illegal 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]:
1070 foo&&foo ;
1071 sort $&foo ;
1072 sort $ &foo ;
1073 EXPECT
1074 Operator or semicolon missing before &foo at - line 3.
1075 Ambiguous use of & resolved as operator & at - line 3.
1076 Operator or semicolon missing before &foo at - line 8.
1077 Ambiguous use of & resolved as operator & at - line 8.
1078 Operator or semicolon missing before &foo at - line 10.
1079 Ambiguous use of & resolved as operator & at - line 10.
1080 Bareword found where operator expected at - line 13, near "$&foo"
1081         (Missing operator before foo?)
1082 Bareword found where operator expected at - line 14, near "$ &foo"
1083         (Missing operator before foo?)
1084 Undefined subroutine &main::foo called at - line 3.
1085 ########
1086 # toke.c
1087 use utf8;
1088 use 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 ;
1098 EXPECT
1099 Operator or semicolon missing before *foo at - line 5.
1100 Ambiguous use of * resolved as operator * at - line 5.
1101 Operator or semicolon missing before *foo at - line 10.
1102 Ambiguous use of * resolved as operator * at - line 10.
1103 Operator or semicolon missing before *foo at - line 12.
1104 Ambiguous use of * resolved as operator * at - line 12.
1105 ########
1106 # toke.c
1107 use warnings 'misc' ;
1108 my $a = "\m" ;
1109 no warnings 'misc' ;
1110 $a = "\m" ;
1111 EXPECT
1112 Unrecognized escape \m passed through at - line 3.
1113 ########
1114 # toke.c
1115 use warnings 'misc' ;
1116 my $a = "abcd\E" ;
1117 no warnings 'misc' ;
1118 $a = "abcd\E" ;
1119 EXPECT
1120 Useless use of \E at - line 3.
1121 ########
1122 # toke.c
1123 use feature 'postderef_qq';
1124 (\$_)->$*;
1125 "$_->$*";
1126 (\$_)->$*;
1127 "$_->$*";
1128 EXPECT
1129 ########
1130 # toke.c
1131 use warnings 'portable' ;
1132 my $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 ;
1141 no 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 ;
1151 EXPECT
1152 Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
1153 Hexadecimal number > 0xffffffff non-portable at - line 8.
1154 Octal number > 037777777777 non-portable at - line 11.
1155 ########
1156 # toke.c
1157 use warnings 'overflow' ;
1158 my $a =  0b011111111111111111111111111111110 ;
1159    $a =  0b011111111111111111111111111111111 ;
1160    $a =  0b10000000000000000000000000000000000000000000000000000000000000000 ;
1161    $a =  0x0fffffffe ;
1162    $a =  0x0ffffffff ;
1163    $a =  0x10000000000000000 ;
1164    $a =  0037777777776 ;
1165    $a =  0037777777777 ;
1166    $a =  002000000000000000000000;
1167 no warnings 'overflow' ;
1168    $a =  0b011111111111111111111111111111110 ;
1169    $a =  0b011111111111111111111111111111111 ;
1170    $a =  0b10000000000000000000000000000000000000000000000000000000000000000 ;
1171    $a =  0x0fffffffe ;
1172    $a =  0x0ffffffff ;
1173    $a =  0x10000000000000000 ;
1174    $a =  0037777777776 ;
1175    $a =  0037777777777 ;
1176    $a =  002000000000000000000000;
1177 EXPECT
1178 Integer overflow in binary number at - line 5.
1179 Integer overflow in hexadecimal number at - line 8.
1180 Integer overflow in octal number at - line 11.
1181 ########
1182 # toke.c
1183 use warnings 'ambiguous';
1184 "@mjd_previously_unused_array";        
1185 no warnings 'ambiguous';
1186 "@mjd_previously_unused_array2";        
1187 EXPECT
1188 Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.
1189 ########
1190 # toke.c
1191 use utf8;
1192 use open qw( :utf8 :std );
1193 use warnings 'ambiguous';
1194 "@mjd_previously_unused_àrray";        
1195 no warnings 'ambiguous';
1196 "@mjd_previously_unused_àrray2";        
1197 EXPECT
1198 Possible unintended interpolation of @mjd_previously_unused_àrray in string at - line 5.
1199 ########
1200 # toke.c
1201 use utf8;
1202 use open qw( :utf8 :std );
1203 use warnings 'ambiguous';
1204 "@mjd_previously_unused_ぁrrぁy";        
1205 no warnings 'ambiguous';
1206 "@mjd_previously_unused_ぁrrぁy2";        
1207 EXPECT
1208 Possible unintended interpolation of @mjd_previously_unused_ぁrrぁy in string at - line 5.
1209 ########
1210 -w
1211 # toke.c
1212 $_ = "@DB::args";        
1213 EXPECT
1214 ########
1215 # toke.c
1216 # 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
1217 use warnings 'regexp';
1218 "foo" =~ /foo/c;
1219 "foo" =~ /foo/cg;
1220 no warnings 'regexp';
1221 "foo" =~ /foo/c;
1222 "foo" =~ /foo/cg;
1223 EXPECT
1224 Use of /c modifier is meaningless without /g at - line 4.
1225 ########
1226 # toke.c
1227 # 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
1228 use warnings 'regexp';
1229 $_ = "ab" ; 
1230 s/ab/ab/c;
1231 s/ab/ab/cg;
1232 no warnings 'regexp';
1233 s/ab/ab/c;
1234 s/ab/ab/cg;
1235 EXPECT
1236 Use of /c modifier is meaningless in s/// at - line 5.
1237 Use of /c modifier is meaningless in s/// at - line 6.
1238 ########
1239 -wa
1240 # toke.c
1241 # 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
1242 print "@F\n";
1243 EXPECT
1244
1245 ########
1246 -w
1247 # toke.c
1248 # 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
1249 print "@F\n";
1250 EXPECT
1251 Possible unintended interpolation of @F in string at - line 4.
1252 Name "main::F" used only once: possible typo at - line 4.
1253 ########
1254 -wa
1255 # toke.c
1256 # 20020414 mjd-perl-patch+@plover.com
1257 EXPECT
1258
1259 ########
1260 # toke.c
1261 # 20020414 mjd-perl-patch+@plover.com
1262 # In 5.7.3, this emitted "Possible unintended interpolation" warnings
1263 use warnings 'ambiguous';
1264 $s = "(@-)(@+)";
1265 EXPECT
1266
1267 ########
1268 # toke.c
1269 # mandatory warning
1270 eval q/if ($a) { } elseif ($b) { }/;
1271 no warnings "syntax";
1272 eval q/if ($a) { } elseif ($b) { }/;
1273 EXPECT
1274 elseif should be elsif at (eval 1) line 1.
1275 ########
1276 # toke.c
1277 # mandatory warning
1278 eval q/5 6/;
1279 no warnings "syntax";
1280 eval q/5 6/;
1281 EXPECT
1282 Number found where operator expected at (eval 1) line 1, near "5 6"
1283         (Missing operator before  6?)
1284 ########
1285 # toke.c
1286 use warnings "syntax"; no warnings "deprecated";
1287 $_ = $a = 1;
1288 $a !=~  /1/;
1289 $a !=~ m#1#;
1290 $a !=~/1/;
1291 $a !=~ y/1//;
1292 $a !=~ tr/1//;
1293 $a !=~ s/1//;
1294 $a != ~/1/;
1295 no warnings "syntax";
1296 $a !=~  /1/;
1297 $a !=~ m#1#;
1298 $a !=~/1/;
1299 $a !=~ y/1//;
1300 $a !=~ tr/1//;
1301 $a !=~ s/1//;
1302 EXPECT
1303 !=~ should be !~ at - line 4.
1304 !=~ should be !~ at - line 5.
1305 !=~ should be !~ at - line 6.
1306 !=~ should be !~ at - line 7.
1307 !=~ should be !~ at - line 8.
1308 !=~ should be !~ at - line 9.
1309 ########
1310 # toke.c
1311 use warnings "syntax";
1312 sub proto_after_array(@$);
1313 sub proto_after_arref(\@$);
1314 sub proto_after_arref2(\[@$]);
1315 sub proto_after_arref3(\[@$]_);
1316 sub proto_after_hash(%$);
1317 sub proto_after_hashref(\%$);
1318 sub proto_after_hashref2(\[%$]);
1319 sub underscore_last_pos($_);
1320 sub underscore2($_;$);
1321 sub underscore_fail($_$); sub underscore_fail2 : prototype($_$);
1322 sub underscore_after_at(@_);
1323 our sub hour (@$);
1324 my sub migh (@$);
1325 use feature 'state';
1326 state sub estate (@$);
1327 package other;
1328 sub hour (@$);
1329 sub migh (@$);
1330 sub estate (@$);
1331 no warnings "syntax";
1332 sub proto_after_array(@$);
1333 sub proto_after_hash(%$);
1334 sub underscore_fail($_$);
1335 EXPECT
1336 Prototype after '@' for main::proto_after_array : @$ at - line 3.
1337 Prototype after '%' for main::proto_after_hash : %$ at - line 7.
1338 Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12.
1339 Illegal character after '_' in prototype for main::underscore_fail2 : $_$ at - line 12.
1340 Prototype after '@' for main::underscore_after_at : @_ at - line 13.
1341 Prototype after '@' for hour : @$ at - line 14.
1342 Prototype after '@' for migh : @$ at - line 15.
1343 Prototype after '@' for estate : @$ at - line 17.
1344 Prototype after '@' for hour : @$ at - line 19.
1345 Prototype after '@' for migh : @$ at - line 20.
1346 Prototype after '@' for estate : @$ at - line 21.
1347 ########
1348 # toke.c
1349 use warnings "ambiguous";
1350 "foo\nn" =~ /^foo$\n/;
1351 "foo\nn" =~ /^foo${\}n/;
1352 my $foo = qr/^foo$\n/;
1353 my $bar = qr/^foo${\}n/;
1354 no warnings "ambiguous";
1355 "foo\nn" =~ /^foo$\n/;
1356 "foo\nn" =~ /^foo${\}n/;
1357 my $foo = qr/^foo$\n/;
1358 my $bar = qr/^foo${\}n/;
1359 EXPECT
1360 Possible unintended interpolation of $\ in regex at - line 3.
1361 Possible unintended interpolation of $\ in regex at - line 5.
1362 ########
1363 # toke.c
1364 use warnings 'syntax' ;
1365 my $a = "\o";
1366 my $a = "\o{";
1367 my $a = "\o{}";
1368 no warnings 'syntax' ;
1369 my $a = "\o";
1370 my $a = "\o{";
1371 my $a = "\o{}";
1372 EXPECT
1373 Missing braces on \o{} at - line 3, within string
1374 Missing right brace on \o{ at - line 4, within string
1375 Empty \o{} at - line 5, within string
1376 BEGIN not safe after errors--compilation aborted at - line 6.
1377 ########
1378 # toke.c
1379 use warnings 'digit' ;
1380 my $a = "\o{1238456}";
1381 no warnings 'digit' ;
1382 my $a = "\o{1238456}";
1383 EXPECT
1384 Non-octal character '8'.  Resolved as "\o{123}" at - line 3.
1385 ########
1386 # toke.c
1387 use warnings;
1388 print ref ? "yes\n" : "no\n" foreach [], ''; # ? is unambiguosly an operator
1389 EXPECT
1390 yes
1391 no
1392 ########
1393 # toke .c
1394 use warnings;
1395 $a =~ ?rand?; # ? is not a regex match
1396 EXPECT
1397 syntax error at - line 3, near "=~ ?"
1398 Execution of - aborted due to compilation errors.
1399 ########
1400 # toke.c
1401 BEGIN {
1402     if (ord('A') == 193) {
1403         print "SKIPPED\n# result varies depending on which ebcdic platform";
1404         exit 0;
1405     }
1406 }
1407 use warnings;
1408 $a = "\c,";
1409 $a = "\c`";
1410 no warnings 'syntax';
1411 $a = "\c,";
1412 $a = "\c`";
1413 EXPECT
1414 "\c," is more clearly written simply as "l" at - line 9.
1415 "\c`" is more clearly written simply as "\ " at - line 10.
1416 ########
1417 # toke.c
1418 BEGIN {
1419     if (ord('A') == 193) {
1420         print "SKIPPED\n# test is ASCII-specific";
1421         exit 0;
1422     }
1423 }
1424 use warnings;
1425 my $a = "\c{ack}";
1426 EXPECT
1427 OPTION fatal
1428 Use ";" instead of "\c{" at - line 9.
1429 ########
1430 # toke.c
1431 BEGIN {
1432     if (ord('A') == 65) {
1433         print "SKIPPED\n# test is EBCDIC-specific";
1434         exit 0;
1435     }
1436 }
1437 use warnings;
1438 my $a = "\c{ack}";
1439 EXPECT
1440 OPTION fatal
1441 Sequence "\c{" invalid at - line 9.
1442 ########
1443 # toke.c
1444 my $a = "\câ";
1445 EXPECT
1446 OPTION fatal
1447 Character following "\c" must be printable ASCII at - line 2.
1448 ########
1449 # toke.c
1450 use warnings 'syntax' ;
1451 my $a = qr/foo/du;
1452 $a = qr/foo/lai;
1453 $a = qr/foo/lil;
1454 $a = qr/foo/aia;
1455 $a = qr/foo/aaia;
1456 no warnings 'syntax' ;
1457 my $a = qr/foo/du;
1458 EXPECT
1459 Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= "
1460 Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= "
1461 Regexp modifier "/l" may not appear twice at - line 5, near "= "
1462 Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= "
1463 BEGIN not safe after errors--compilation aborted at - line 8.
1464 ########
1465 # toke.c
1466 # [perl #4362]
1467 eval "print q\xabfoo";
1468 print "ok\n" if
1469     $@ =~ /Can't find string terminator "\xab" anywhere before EOF/;
1470 EXPECT
1471 ok
1472 ########
1473 # toke.c
1474 use utf8;
1475 use open qw( :utf8 :std );
1476 use warnings 'ambiguous' ;
1477 sub frèd {}
1478 $a = ${frèd} ;
1479 no warnings 'ambiguous' ;
1480 $a = ${frèd} ;
1481 EXPECT
1482 Ambiguous use of ${frèd} resolved to $frèd at - line 6.
1483 ########
1484 # toke.c
1485 use utf8;
1486 use open qw( :utf8 :std );
1487 use warnings 'ambiguous' ;
1488 sub f렏 {}
1489 $a = ${f렏} ;
1490 no warnings 'ambiguous' ;
1491 $a = ${f렏} ;
1492 EXPECT
1493 Ambiguous use of ${f렏} resolved to $f렏 at - line 6.
1494 ########
1495 # toke.c
1496 use utf8;
1497 use open qw( :utf8 :std );
1498 use warnings;
1499 CORE::렏;
1500 EXPECT
1501 CORE::렏 is not a keyword at - line 5.
1502 ########
1503 # toke.c
1504 # [perl #16249]
1505 print '';
1506 eval this_method_is_fake ();
1507 EXPECT
1508 Undefined subroutine &main::this_method_is_fake called at - line 4.
1509 ########
1510 # toke.c
1511 # [perl #107002] Erroneous ambiguity warnings
1512 sub { # do not actually call require
1513   require a::b . 1; # These used to produce erroneous
1514   require a::b + 1; # ambiguity warnings.
1515 }
1516 EXPECT
1517 ########
1518 # toke.c
1519 # [perl #113094], [perl #119101], since reverted so no warnings generated
1520 use warnings;
1521 print "aa" =~ m{^a\{1,2\}$}, "A\n";
1522 print "aa" =~ m{^a\x\{61\}$}, "B\n";
1523 print "a\\x{6F}" =~ m{^a\\x\{6F\}$}, "C\n";
1524 print "a\\o" =~ m{^a\\\x\{6F\}$}, "D\n";
1525 print "a\\\\x{6F}" =~ m{^a\\\\x\{6F\}$}, "E\n";
1526 print "a\\\\o"     =~ m{^a\\\\\x\{6F\}$}, "F\n";
1527 print "aa" =~ m{^a{1,2}$}, "G\n";
1528 print "aq" =~ m[^a\[a-z\]$], "H\n";
1529 print "aq" =~ m(^a\(q\)$), "I\n";
1530 EXPECT
1531 Illegal hexadecimal digit '\' ignored at - line 5.
1532 Illegal hexadecimal digit '\' ignored at - line 7.
1533 Illegal hexadecimal digit '\' ignored at - line 9.
1534 A
1535 B
1536 1C
1537 D
1538 1E
1539 F
1540 1G
1541 H
1542 I
1543 ########
1544 # toke.c
1545 #[perl #119123] disallow literal control character variables
1546 *{
1547     Foo
1548 }; # shouldn't warn on {\n, even though \n is a control character
1549 EXPECT
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;
1556 EXPECT
1557 ########
1558 # toke.c
1559 # [perl #124113] Compile-time warning with UTF8 variable in array index
1560 use warnings;
1561 use utf8;
1562 my $𝛃 = 0;
1563 my @array = (0);
1564 my $v = $array[ 0 + $𝛃 ];
1565    $v = $array[ $𝛃 + 0 ];
1566 EXPECT
1567 ########
1568 # toke.c
1569 # Allow Unicode here doc boundaries
1570 use warnings;
1571 use utf8;
1572 my $v = <<EnFraçais;
1573 Comme ca!
1574 EnFraçais
1575 print $v;
1576 EXPECT
1577 Comme ca!
1578 ########
1579 # toke.c
1580 # Fix 'Use of "..." without parentheses is ambiguous' warning for
1581 # Unicode function names.  If not under PERL_UNICODE, this will generate
1582 # a "Wide character" warning
1583 use utf8;
1584 use warnings;
1585 sub 𝛃(;$) { return 0; }
1586 my $v = 𝛃 - 5;
1587 EXPECT
1588 OPTION regex
1589 (Wide character.*\n)?Warning: Use of "𝛃" without parentheses is ambiguous
1590 ########
1591 # RT #4346 Case 1: Warnings for print (...)
1592 # TODO RT #4346: Warnings for print(...) are inconsistent
1593 use warnings;
1594 print ("((\n");
1595 print (">>\n");
1596 EXPECT
1597 print (...) interpreted as function at - line 3.
1598 print (...) interpreted as function at - line 4.
1599 ((
1600 >>
1601 ########
1602 # RT #4346 Case 2: Warnings for print (...)
1603 use warnings;
1604 print ("((\n");
1605 print (">>\n")
1606 EXPECT
1607 print (...) interpreted as function at - line 3.
1608 print (...) 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
1614 use warnings;
1615 print (">>\n");
1616 print ("((\n");
1617 EXPECT
1618 print (...) interpreted as function at - line 3.
1619 print (...) 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
1625 use warnings;
1626 print (")\n");
1627 print ("))\n");
1628 EXPECT
1629 print (...) interpreted as function at - line 3.
1630 print (...) interpreted as function at - line 4.
1631 )
1632 ))
1633 ########
1634 # NAME  Non-grapheme delimiters
1635 BEGIN{
1636     if (ord('A') == 193) {
1637         print "SKIPPED\n# ebcdic platforms generates different Malformed UTF-8 warnings.";
1638         exit 0;
1639     }
1640 }
1641 use utf8;
1642 my $a = qr ̂foobar̂;
1643 EXPECT
1644 Use of unassigned code point or non-standalone grapheme for a delimiter is not allowed at - line 8, near "= "
1645 Use of unassigned code point or non-standalone grapheme for a delimiter is not allowed at - line 8, near "= "
1646 Execution of - aborted due to compilation errors.
1647 ########
1648 # NAME  [perl #130567] Assertion failure
1649 BEGIN {
1650     if (ord('A') != 65) {
1651         print "SKIPPED\n# test is ASCII-specific";
1652         exit 0;
1653     }
1654 }
1655 no warnings "uninitialized";
1656 $_= "";
1657 s//\3000/;
1658 s//"\x{180};;s\221(*$@$`\241\275";/gee;
1659 s//"s\221\302\302\302\302\302\302\302$@\241\275";/gee;
1660 EXPECT
1661 ########
1662 # NAME  [perl #130666] Assertion failure
1663 no warnings "uninitialized";
1664 BEGIN{$^H=-1};my $l; s\0$0[$l]\0\0
1665 EXPECT
1666 ########
1667 # NAME  [perl #129036] Assertion failure
1668 BEGIN{$0="";$^H=hex join""=>A00000}p?
1669 EXPECT
1670 OPTION fatal
1671 syntax error at - line 1, at EOF
1672 Execution of - aborted due to compilation errors.
1673 ########
1674 # NAME  [perl #130655]
1675 use utf8;
1676 qw∘foo ∞ ♥ bar∘
1677 EXPECT