This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
4c6c8fe6a233c063614f2164621857178579519f
[perl5.git] / t / lib / warnings / toke
1 toke.c  AOK
2
3     we seem to have lost a few ambiguous warnings!!
4
5  
6                 $a = <<;
7                 Use of comma-less variable list is deprecated 
8                 (called 3 times via depcom)
9
10      \1 better written as $1 
11         use warnings 'syntax' ;
12         s/(abc)/\1/;
13  
14      warn(warn_nosemi) 
15      Semicolon seems to be missing
16         $a = 1
17         &time ;
18
19
20      Reversed %c= operator 
21         my $a =+ 2 ;
22         $a =- 2 ;
23         $a =* 2 ;
24         $a =% 2 ;
25         $a =& 2 ;
26         $a =. 2 ;
27         $a =^ 2 ;
28         $a =| 2 ;
29         $a =< 2 ;
30         $a =/ 2 ;
31
32      Multidimensional syntax %.*s not supported 
33         my $a = $a[1,2] ;
34
35      You need to quote \"%s\"" 
36         sub fred {} ; $SIG{TERM} = fred;
37
38      Scalar value %.*s better written as $%.*s" 
39         @a[3] = 2;
40         @a{3} = 2;
41
42      Can't use \\%c to mean $%c in expression 
43         $_ = "ab" ; s/(ab)/\1/e;
44
45      Unquoted string "abc" may clash with future reserved word at - line 3.
46      warn(warn_reserved 
47         $a = abc;
48
49      Possible attempt to separate words with commas 
50         @a = qw(a, b, c) ;
51
52      Possible attempt to put comments in qw() list 
53         @a = qw(a b # c) ;
54
55      %s (...) interpreted as function 
56         print ("")
57         printf ("")
58         sort ("")
59
60      Ambiguous use of %c{%s%s} resolved to %c%s%s 
61         $a = ${time[2]}
62         $a = ${time{2}}
63
64
65      Ambiguous use of %c{%s} resolved to %c%s
66         $a = ${time}
67         sub fred {} $a = ${fred}
68
69      Misplaced _ in number 
70         $a = 1_2;
71         $a = 1_2345_6;
72
73     Bareword \"%s\" refers to nonexistent package
74         $a = FRED:: ;
75
76     Ambiguous call resolved as CORE::%s(), qualify as such or use &
77         sub time {} 
78         my $a = time()
79
80     Unrecognized escape \\%c passed through
81         $a = "\m" ;
82
83     Useless use of \\E.
84         $a = "abcd\E" ;
85
86     %s number > %s non-portable
87         my $a =  0b011111111111111111111111111111110 ;
88         $a =  0b011111111111111111111111111111111 ;
89         $a =  0b111111111111111111111111111111111 ;
90         $a =  0x0fffffffe ;
91         $a =  0x0ffffffff ;
92         $a =  0x1ffffffff ;
93         $a =  0037777777776 ;
94         $a =  0037777777777 ;
95         $a =  0047777777777 ;
96
97     Integer overflow in binary number
98         my $a =  0b011111111111111111111111111111110 ;
99         $a =  0b011111111111111111111111111111111 ;
100         $a =  0b111111111111111111111111111111111 ;
101         $a =  0x0fffffffe ;
102         $a =  0x0ffffffff ;
103         $a =  0x1ffffffff ;
104         $a =  0037777777776 ;
105         $a =  0037777777777 ;
106         $a =  0047777777777 ;
107
108     dump() better written as CORE::dump()
109
110     Use of /c modifier is meaningless without /g     
111
112     Use of /c modifier is meaningless in s///
113
114     Mandatory Warnings
115     ------------------
116     Use of "%s" without parentheses is ambiguous        [check_uni]
117         rand + 4 
118
119     Ambiguous use of -%s resolved as -&%s()             [yylex]
120         sub fred {} ; - fred ;
121
122     Precedence problem: open %.*s should be open(%.*s)  [yylex]
123         open FOO || die;
124
125     Operator or semicolon missing before %c%s           [yylex]
126     Ambiguous use of %c resolved as operator %c
127         *foo *foo
128
129 __END__
130 # toke.c 
131 format STDOUT =
132 @<<<  @|||  @>>>  @>>>
133 $a    $b    "abc" 'def'
134 .
135 no warnings 'deprecated' ;
136 format STDOUT =
137 @<<<  @|||  @>>>  @>>>
138 $a    $b    "abc" 'def'
139 .
140 EXPECT
141 Use of comma-less variable list is deprecated at - line 4.
142 Use of comma-less variable list is deprecated at - line 4.
143 Use of comma-less variable list is deprecated at - line 4.
144 ########
145 # toke.c
146 $a =~ m/$foo/sand $bar;
147 $a =~ s/$foo/fool/sand $bar;
148 $a = <<;
149
150 no warnings 'deprecated' ;
151 $a =~ m/$foo/sand $bar;
152 $a =~ s/$foo/fool/sand $bar;
153 $a = <<;
154
155 EXPECT
156 Having no space between pattern and following word is deprecated at - line 2.
157 Having no space between pattern and following word is deprecated at - line 3.
158 Use of bare << to mean <<"" is deprecated at - line 4.
159 ########
160 # toke.c
161 use warnings 'syntax' ;
162 s/(abc)/\1/;
163 no warnings 'syntax' ;
164 s/(abc)/\1/;
165 EXPECT
166 \1 better written as $1 at - line 3.
167 ########
168 # toke.c
169 use warnings 'semicolon' ;
170 $a = 1
171 &time ;
172 no warnings 'semicolon' ;
173 $a = 1
174 &time ;
175 EXPECT
176 Semicolon seems to be missing at - line 3.
177 ########
178 # toke.c
179 use warnings 'syntax' ;
180 my $a =+ 2 ;
181 $a =- 2 ;
182 $a =* 2 ;
183 $a =% 2 ;
184 $a =& 2 ;
185 $a =. 2 ;
186 $a =^ 2 ;
187 $a =| 2 ;
188 $a =< 2 ;
189 $a =/ 2 ;
190 EXPECT
191 Reversed += operator at - line 3.
192 Reversed -= operator at - line 4.
193 Reversed *= operator at - line 5.
194 Reversed %= operator at - line 6.
195 Reversed &= operator at - line 7.
196 Reversed .= operator at - line 8.
197 Reversed ^= operator at - line 9.
198 Reversed |= operator at - line 10.
199 Reversed <= operator at - line 11.
200 syntax error at - line 8, near "=."
201 syntax error at - line 9, near "=^"
202 syntax error at - line 10, near "=|"
203 Unterminated <> operator at - line 11.
204 ########
205 # toke.c
206 no warnings 'syntax' ;
207 my $a =+ 2 ;
208 $a =- 2 ;
209 $a =* 2 ;
210 $a =% 2 ;
211 $a =& 2 ;
212 $a =. 2 ;
213 $a =^ 2 ;
214 $a =| 2 ;
215 $a =< 2 ;
216 $a =/ 2 ;
217 EXPECT
218 syntax error at - line 8, near "=."
219 syntax error at - line 9, near "=^"
220 syntax error at - line 10, near "=|"
221 Unterminated <> operator at - line 11.
222 ########
223 # toke.c
224 use warnings 'syntax' ;
225 my $a = $a[1,2] ;
226 no warnings 'syntax' ;
227 my $a = $a[1,2] ;
228 EXPECT
229 Multidimensional syntax $a[1,2] not supported at - line 3.
230 ########
231 # toke.c
232 use warnings 'syntax' ;
233 sub fred {} ; $SIG{TERM} = fred;
234 no warnings 'syntax' ;
235 $SIG{TERM} = fred;
236 EXPECT
237 You need to quote "fred" at - line 3.
238 ########
239 # toke.c
240 use warnings 'syntax' ;
241 @a[3] = 2;
242 @a{3} = 2;
243 no warnings 'syntax' ;
244 @a[3] = 2;
245 @a{3} = 2;
246 EXPECT
247 Scalar value @a[3] better written as $a[3] at - line 3.
248 Scalar value @a{3} better written as $a{3} at - line 4.
249 ########
250 # toke.c
251 use warnings 'syntax' ;
252 $_ = "ab" ; 
253 s/(ab)/\1/e;
254 no warnings 'syntax' ;
255 $_ = "ab" ; 
256 s/(ab)/\1/e;
257 EXPECT
258 Can't use \1 to mean $1 in expression at - line 4.
259 ########
260 # toke.c
261 use warnings 'reserved' ;
262 $a = abc;
263 $a = { def
264
265 => 1 };
266 no warnings 'reserved' ;
267 $a = abc;
268 EXPECT
269 Unquoted string "abc" may clash with future reserved word at - line 3.
270 ########
271 # toke.c
272 use warnings 'qw' ;
273 @a = qw(a, b, c) ;
274 no warnings 'qw' ;
275 @a = qw(a, b, c) ;
276 EXPECT
277 Possible attempt to separate words with commas at - line 3.
278 ########
279 # toke.c
280 use warnings 'qw' ;
281 @a = qw(a b c # #) ;
282 no warnings 'qw' ;
283 @a = qw(a b c # #) ;
284 EXPECT
285 Possible attempt to put comments in qw() list at - line 3.
286 ########
287 # toke.c
288 use warnings 'qw' ;
289 @a = qw(a, b, c # #) ;
290 no warnings 'qw' ;
291 @a = qw(a, b, c # #) ;
292 EXPECT
293 Possible attempt to separate words with commas at - line 3.
294 Possible attempt to put comments in qw() list at - line 3.
295 ########
296 # toke.c
297 use warnings 'syntax' ;
298 print ("");
299 print ("") and $x = 1;
300 print ("") or die;
301 print ("") // die;
302 print (1+2) * 3 if 0; # only this one should warn
303 print (1+2) if 0;
304 EXPECT
305 print (...) interpreted as function at - line 7.
306 ########
307 # toke.c
308 no warnings 'syntax' ;
309 print ("")
310 EXPECT
311
312 ########
313 # toke.c
314 use warnings 'syntax' ;
315 printf ("");
316 printf ("") . '';
317 EXPECT
318 printf (...) interpreted as function at - line 4.
319 ########
320 # toke.c
321 no warnings 'syntax' ;
322 printf ("")
323 EXPECT
324
325 ########
326 # toke.c
327 use warnings 'syntax' ;
328 sort ("");
329 sort ("") . '';
330 EXPECT
331 sort (...) interpreted as function at - line 4.
332 ########
333 # toke.c
334 no warnings 'syntax' ;
335 sort ("")
336 EXPECT
337
338 ########
339 # toke.c
340 use warnings 'ambiguous' ;
341 $a = ${time[2]};
342 no warnings 'ambiguous' ;
343 $a = ${time[2]};
344 EXPECT
345 Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
346 ########
347 # toke.c
348 use warnings 'ambiguous' ;
349 $a = ${time{2}};
350 EXPECT
351 Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
352 ########
353 # toke.c
354 no warnings 'ambiguous' ;
355 $a = ${time{2}};
356 EXPECT
357
358 ########
359 # toke.c
360 use warnings 'ambiguous' ;
361 $a = ${time} ;
362 no warnings 'ambiguous' ;
363 $a = ${time} ;
364 EXPECT
365 Ambiguous use of ${time} resolved to $time at - line 3.
366 ########
367 # toke.c
368 use warnings 'ambiguous' ;
369 sub fred {}
370 $a = ${fred} ;
371 no warnings 'ambiguous' ;
372 $a = ${fred} ;
373 EXPECT
374 Ambiguous use of ${fred} resolved to $fred at - line 4.
375 ########
376 # toke.c
377 use warnings 'syntax' ;
378 $a = _123; print "$a\n";                #( 3    string)
379 $a = 1_23; print "$a\n";
380 $a = 12_3; print "$a\n";
381 $a = 123_; print "$a\n";                #  6
382 $a = _+123; print "$a\n";               #  7    string)
383 $a = +_123; print "$a\n";               #( 8    string)
384 $a = +1_23; print "$a\n";
385 $a = +12_3; print "$a\n";
386 $a = +123_; print "$a\n";               # 11
387 $a = _-123; print "$a\n";               #(12    string)
388 $a = -_123; print "$a\n";               #(13    string)
389 $a = -1_23; print "$a\n";
390 $a = -12_3; print "$a\n";
391 $a = -123_; print "$a\n";               # 16
392 $a = 123._456; print "$a\n";            # 17
393 $a = 123.4_56; print "$a\n";
394 $a = 123.45_6; print "$a\n";
395 $a = 123.456_; print "$a\n";            # 20
396 $a = +123._456; print "$a\n";           # 21
397 $a = +123.4_56; print "$a\n";   
398 $a = +123.45_6; print "$a\n";   
399 $a = +123.456_; print "$a\n";           # 24
400 $a = -123._456; print "$a\n";           # 25
401 $a = -123.4_56; print "$a\n";   
402 $a = -123.45_6; print "$a\n";
403 $a = -123.456_; print "$a\n";           # 28
404 $a = 123.456E_12; printf("%.0f\n", $a); # 29
405 $a = 123.456E1_2; printf("%.0f\n", $a);
406 $a = 123.456E12_; printf("%.0f\n", $a); # 31
407 $a = 123.456E_+12; printf("%.0f\n", $a);        # 32
408 $a = 123.456E+_12; printf("%.0f\n", $a);        # 33
409 $a = 123.456E+1_2; printf("%.0f\n", $a);
410 $a = 123.456E+12_; printf("%.0f\n", $a);        # 35
411 $a = 123.456E_-12; print "$a\n";        # 36
412 $a = 123.456E-_12; print "$a\n";        # 37
413 $a = 123.456E-1_2; print "$a\n";
414 $a = 123.456E-12_; print "$a\n";        # 39
415 $a = 1__23; print "$a\n";               # 40
416 $a = 12.3__4; print "$a\n";             # 41
417 $a = 12.34e1__2; printf("%.0f\n", $a);  # 42
418 no warnings 'syntax' ;
419 $a = _123; print "$a\n";
420 $a = 1_23; print "$a\n";
421 $a = 12_3; print "$a\n";
422 $a = 123_; print "$a\n";
423 $a = _+123; print "$a\n";
424 $a = +_123; print "$a\n";
425 $a = +1_23; print "$a\n";
426 $a = +12_3; print "$a\n";
427 $a = +123_; print "$a\n";
428 $a = _-123; print "$a\n";
429 $a = -_123; print "$a\n";
430 $a = -1_23; print "$a\n";
431 $a = -12_3; print "$a\n";
432 $a = -123_; print "$a\n";
433 $a = 123._456; print "$a\n";
434 $a = 123.4_56; print "$a\n";
435 $a = 123.45_6; print "$a\n";
436 $a = 123.456_; print "$a\n";
437 $a = +123._456; print "$a\n";
438 $a = +123.4_56; print "$a\n";
439 $a = +123.45_6; print "$a\n";
440 $a = +123.456_; print "$a\n";
441 $a = -123._456; print "$a\n";
442 $a = -123.4_56; print "$a\n";
443 $a = -123.45_6; print "$a\n";
444 $a = -123.456_; print "$a\n";
445 $a = 123.456E_12; printf("%.0f\n", $a);
446 $a = 123.456E1_2; printf("%.0f\n", $a);
447 $a = 123.456E12_; printf("%.0f\n", $a);
448 $a = 123.456E_+12; printf("%.0f\n", $a);
449 $a = 123.456E+_12; printf("%.0f\n", $a);
450 $a = 123.456E+1_2; printf("%.0f\n", $a);
451 $a = 123.456E+12_; printf("%.0f\n", $a);
452 $a = 123.456E_-12; print "$a\n";
453 $a = 123.456E-_12; print "$a\n";
454 $a = 123.456E-1_2; print "$a\n";
455 $a = 123.456E-12_; print "$a\n";
456 $a = 1__23; print "$a\n";
457 $a = 12.3__4; print "$a\n";
458 $a = 12.34e1__2; printf("%.0f\n", $a);
459 EXPECT
460 OPTIONS regex
461 Misplaced _ in number at - line 6.
462 Misplaced _ in number at - line 11.
463 Misplaced _ in number at - line 16.
464 Misplaced _ in number at - line 17.
465 Misplaced _ in number at - line 20.
466 Misplaced _ in number at - line 21.
467 Misplaced _ in number at - line 24.
468 Misplaced _ in number at - line 25.
469 Misplaced _ in number at - line 28.
470 Misplaced _ in number at - line 29.
471 Misplaced _ in number at - line 31.
472 Misplaced _ in number at - line 32.
473 Misplaced _ in number at - line 33.
474 Misplaced _ in number at - line 35.
475 Misplaced _ in number at - line 36.
476 Misplaced _ in number at - line 37.
477 Misplaced _ in number at - line 39.
478 Misplaced _ in number at - line 40.
479 Misplaced _ in number at - line 41.
480 Misplaced _ in number at - line 42.
481 _123
482 123
483 123
484 123
485 123
486 _123
487 123
488 123
489 123
490 -123
491 -_123
492 -123
493 -123
494 -123
495 123.456
496 123.456
497 123.456
498 123.456
499 123.456
500 123.456
501 123.456
502 123.456
503 -123.456
504 -123.456
505 -123.456
506 -123.456
507 123456000000000
508 123456000000000
509 123456000000000
510 123456000000000
511 123456000000000
512 123456000000000
513 123456000000000
514 1.23456e-0?10
515 1.23456e-0?10
516 1.23456e-0?10
517 1.23456e-0?10
518 123
519 12.34
520 12340000000000
521 _123
522 123
523 123
524 123
525 123
526 _123
527 123
528 123
529 123
530 -123
531 -_123
532 -123
533 -123
534 -123
535 123.456
536 123.456
537 123.456
538 123.456
539 123.456
540 123.456
541 123.456
542 123.456
543 -123.456
544 -123.456
545 -123.456
546 -123.456
547 123456000000000
548 123456000000000
549 123456000000000
550 123456000000000
551 123456000000000
552 123456000000000
553 123456000000000
554 1.23456e-0?10
555 1.23456e-0?10
556 1.23456e-0?10
557 1.23456e-0?10
558 123
559 12.34
560 12340000000000
561 ########
562 # toke.c
563 use warnings 'bareword' ;
564 #line 25 "bar"
565 $a = FRED:: ;
566 no warnings 'bareword' ;
567 #line 25 "bar"
568 $a = FRED:: ;
569 EXPECT
570 Bareword "FRED::" refers to nonexistent package at bar line 25.
571 ########
572 # toke.c
573 use warnings 'ambiguous' ;
574 sub time {}
575 my $a = time() ;
576 no warnings 'ambiguous' ;
577 my $b = time() ;
578 EXPECT
579 Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
580 ########
581 # toke.c
582 use warnings ;
583 eval <<'EOE';
584 #  line 30 "foo"
585 warn "yelp";
586 {
587   $_ = " \x{123} " ;
588 }
589 EOE
590 EXPECT
591 yelp at foo line 30.
592 ########
593 # toke.c
594 my $a = rand + 4 ;
595 EXPECT
596 Warning: Use of "rand" without parentheses is ambiguous at - line 2.
597 ########
598 # toke.c
599 $^W = 0 ;
600 my $a = rand + 4 ;
601 {
602     no warnings 'ambiguous' ;
603     $a = rand + 4 ;
604     use warnings 'ambiguous' ;
605     $a = rand + 4 ;
606 }
607 $a = rand + 4 ;
608 EXPECT
609 Warning: Use of "rand" without parentheses is ambiguous at - line 3.
610 Warning: Use of "rand" without parentheses is ambiguous at - line 8.
611 Warning: Use of "rand" without parentheses is ambiguous at - line 10.
612 ########
613 # [perl #97110]
614 sub myrand(;$) { }
615 sub whatever($) { }
616 my $a = myrand + 4 ;
617 my $b = whatever + 4 ;
618 EXPECT
619 Warning: Use of "myrand" without parentheses is ambiguous at - line 4.
620 ########
621 # toke.c
622 use warnings "ambiguous";
623 print for keys %+; # should not warn
624 EXPECT
625 ########
626 # toke.c
627 sub fred {};
628 -fred ;
629 EXPECT
630 Ambiguous use of -fred resolved as -&fred() at - line 3.
631 ########
632 # toke.c
633 $^W = 0 ;
634 sub fred {} ;
635 -fred ;
636 {
637     no warnings 'ambiguous' ;
638     -fred ;
639     use warnings 'ambiguous' ;
640     -fred ;
641 }
642 -fred ;
643 EXPECT
644 Ambiguous use of -fred resolved as -&fred() at - line 4.
645 Ambiguous use of -fred resolved as -&fred() at - line 9.
646 Ambiguous use of -fred resolved as -&fred() at - line 11.
647 ########
648 # toke.c
649 open FOO || time;
650 open local *FOO; # should be ok
651 EXPECT
652 Precedence problem: open FOO should be open(FOO) at - line 2.
653 ########
654 # toke.c (and [perl #16184])
655 open FOO => "<&0"; close FOO;
656 EXPECT
657 ########
658 # toke.c
659 $^W = 0 ;
660 open FOO || time;
661 {
662     no warnings 'precedence' ;
663     open FOO || time;
664     use warnings 'precedence' ;
665     open FOO || time;
666 }
667 open FOO || time;
668 open Foo::BAR; # this should not warn
669 EXPECT
670 Precedence problem: open FOO should be open(FOO) at - line 3.
671 Precedence problem: open FOO should be open(FOO) at - line 8.
672 Precedence problem: open FOO should be open(FOO) at - line 10.
673 ########
674 # toke.c
675 $^W = 0 ;
676 *foo *foo ;
677 {
678     no warnings 'ambiguous' ;
679     *foo *foo ;
680     use warnings 'ambiguous' ;
681     *foo *foo ;
682 }
683 *foo *foo ;
684 EXPECT
685 Operator or semicolon missing before *foo at - line 3.
686 Ambiguous use of * resolved as operator * at - line 3.
687 Operator or semicolon missing before *foo at - line 8.
688 Ambiguous use of * resolved as operator * at - line 8.
689 Operator or semicolon missing before *foo at - line 10.
690 Ambiguous use of * resolved as operator * at - line 10.
691 ########
692 # toke.c
693 use warnings 'misc' ;
694 my $a = "\m" ;
695 no warnings 'misc' ;
696 $a = "\m" ;
697 EXPECT
698 Unrecognized escape \m passed through at - line 3.
699 ########
700 # toke.c
701 use warnings 'misc' ;
702 my $a = "abcd\E" ;
703 no warnings 'misc' ;
704 $a = "abcd\E" ;
705 EXPECT
706 Useless use of \E at - line 3.
707 ########
708 # toke.c
709 use warnings 'portable' ;
710 my $a =  0b011111111111111111111111111111110 ;
711    $a =  0b011111111111111111111111111111111 ;
712    $a =  0b111111111111111111111111111111111 ;
713    $a =  0x0fffffffe ;
714    $a =  0x0ffffffff ;
715    $a =  0x1ffffffff ;
716    $a =  0037777777776 ;
717    $a =  0037777777777 ;
718    $a =  0047777777777 ;
719 no warnings 'portable' ;
720    $a =  0b011111111111111111111111111111110 ;
721    $a =  0b011111111111111111111111111111111 ;
722    $a =  0b111111111111111111111111111111111 ;
723    $a =  0x0fffffffe ;
724    $a =  0x0ffffffff ;
725    $a =  0x1ffffffff ;
726    $a =  0037777777776 ;
727    $a =  0037777777777 ;
728    $a =  0047777777777 ;
729 EXPECT
730 Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
731 Hexadecimal number > 0xffffffff non-portable at - line 8.
732 Octal number > 037777777777 non-portable at - line 11.
733 ########
734 # toke.c
735 use warnings 'overflow' ;
736 my $a =  0b011111111111111111111111111111110 ;
737    $a =  0b011111111111111111111111111111111 ;
738    $a =  0b10000000000000000000000000000000000000000000000000000000000000000 ;
739    $a =  0x0fffffffe ;
740    $a =  0x0ffffffff ;
741    $a =  0x10000000000000000 ;
742    $a =  0037777777776 ;
743    $a =  0037777777777 ;
744    $a =  002000000000000000000000;
745 no warnings 'overflow' ;
746    $a =  0b011111111111111111111111111111110 ;
747    $a =  0b011111111111111111111111111111111 ;
748    $a =  0b10000000000000000000000000000000000000000000000000000000000000000 ;
749    $a =  0x0fffffffe ;
750    $a =  0x0ffffffff ;
751    $a =  0x10000000000000000 ;
752    $a =  0037777777776 ;
753    $a =  0037777777777 ;
754    $a =  002000000000000000000000;
755 EXPECT
756 Integer overflow in binary number at - line 5.
757 Integer overflow in hexadecimal number at - line 8.
758 Integer overflow in octal number at - line 11.
759 ########
760 # toke.c
761 BEGIN { $^C = 1; }
762 use warnings 'misc';
763 dump;
764 CORE::dump;
765 EXPECT
766 dump() better written as CORE::dump() at - line 4.
767 - syntax OK
768 ########
769 # toke.c
770 use warnings 'misc';
771 use subs qw/dump/;
772 sub dump { print "no warning for overridden dump\n"; }
773 dump;
774 EXPECT
775 no warning for overridden dump
776 ########
777 # toke.c
778 use warnings 'ambiguous';
779 "@mjd_previously_unused_array";        
780 no warnings 'ambiguous';
781 "@mjd_previously_unused_array";        
782 EXPECT
783 Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.
784 ########
785 # toke.c
786 # 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
787 use warnings 'regexp';
788 "foo" =~ /foo/c;
789 "foo" =~ /foo/cg;
790 no warnings 'regexp';
791 "foo" =~ /foo/c;
792 "foo" =~ /foo/cg;
793 EXPECT
794 Use of /c modifier is meaningless without /g at - line 4.
795 ########
796 # toke.c
797 # 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
798 use warnings 'regexp';
799 $_ = "ab" ; 
800 s/ab/ab/c;
801 s/ab/ab/cg;
802 no warnings 'regexp';
803 s/ab/ab/c;
804 s/ab/ab/cg;
805 EXPECT
806 Use of /c modifier is meaningless in s/// at - line 5.
807 Use of /c modifier is meaningless in s/// at - line 6.
808 ########
809 -wa
810 # toke.c
811 # 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
812 print "@F\n";
813 EXPECT
814
815 ########
816 -w
817 # toke.c
818 # 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
819 print "@F\n";
820 EXPECT
821 Possible unintended interpolation of @F in string at - line 4.
822 Name "main::F" used only once: possible typo at - line 4.
823 ########
824 -wa
825 # toke.c
826 # 20020414 mjd-perl-patch+@plover.com
827 EXPECT
828
829 ########
830 # toke.c
831 # 20020414 mjd-perl-patch+@plover.com
832 # In 5.7.3, this emitted "Possible unintended interpolation" warnings
833 use warnings 'ambiguous';
834 $s = "(@-)(@+)";
835 EXPECT
836
837 ########
838 # toke.c
839 # mandatory warning
840 eval q/if ($a) { } elseif ($b) { }/;
841 no warnings "syntax";
842 eval q/if ($a) { } elseif ($b) { }/;
843 EXPECT
844 elseif should be elsif at (eval 1) line 1.
845 ########
846 # toke.c
847 # mandatory warning
848 eval q/5 6/;
849 no warnings "syntax";
850 eval q/5 6/;
851 EXPECT
852 Number found where operator expected at (eval 1) line 1, near "5 6"
853         (Missing operator before  6?)
854 ########
855 # toke.c
856 use warnings "syntax";
857 $_ = $a = 1;
858 $a !=~  /1/;
859 $a !=~ m#1#;
860 $a !=~/1/;
861 $a !=~ ?/?;
862 $a !=~ y/1//;
863 $a !=~ tr/1//;
864 $a !=~ s/1//;
865 $a != ~/1/;
866 no warnings "syntax";
867 $a !=~  /1/;
868 $a !=~ m#1#;
869 $a !=~/1/;
870 $a !=~ ?/?;
871 $a !=~ y/1//;
872 $a !=~ tr/1//;
873 $a !=~ s/1//;
874 EXPECT
875 !=~ should be !~ at - line 4.
876 !=~ should be !~ at - line 5.
877 !=~ should be !~ at - line 6.
878 !=~ should be !~ at - line 7.
879 !=~ should be !~ at - line 8.
880 !=~ should be !~ at - line 9.
881 !=~ should be !~ at - line 10.
882 ########
883 # toke.c
884 our $foo :unique;
885 sub pam :locked;
886 sub glipp :locked {
887 }
888 sub whack_eth ($) : locked {
889 }
890 no warnings 'deprecated';
891 our $bar :unique;
892 sub zapeth :locked;
893 sub ker_plop :locked {
894 }
895 sub swa_a_p ($) : locked {
896 }
897 EXPECT
898 Use of :unique is deprecated at - line 2.
899 Use of :locked is deprecated at - line 3.
900 Use of :locked is deprecated at - line 4.
901 Use of :locked is deprecated at - line 6.
902 ########
903 # toke.c
904 use warnings "syntax";
905 sub proto_after_array(@$);
906 sub proto_after_arref(\@$);
907 sub proto_after_arref2(\[@$]);
908 sub proto_after_arref3(\[@$]_);
909 sub proto_after_hash(%$);
910 sub proto_after_hashref(\%$);
911 sub proto_after_hashref2(\[%$]);
912 sub underscore_last_pos($_);
913 sub underscore2($_;$);
914 sub underscore_fail($_$);
915 sub underscore_after_at(@_);
916 no warnings "syntax";
917 sub proto_after_array(@$);
918 sub proto_after_hash(%$);
919 sub underscore_fail($_$);
920 EXPECT
921 Prototype after '@' for main::proto_after_array : @$ at - line 3.
922 Prototype after '%' for main::proto_after_hash : %$ at - line 7.
923 Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12.
924 Prototype after '@' for main::underscore_after_at : @_ at - line 13.
925 ########
926 # toke.c
927 use warnings "ambiguous";
928 "foo\nn" =~ /^foo$\n/;
929 "foo\nn" =~ /^foo${\}n/;
930 my $foo = qr/^foo$\n/;
931 my $bar = qr/^foo${\}n/;
932 no warnings "ambiguous";
933 "foo\nn" =~ /^foo$\n/;
934 "foo\nn" =~ /^foo${\}n/;
935 my $foo = qr/^foo$\n/;
936 my $bar = qr/^foo${\}n/;
937 EXPECT
938 Possible unintended interpolation of $\ in regex at - line 3.
939 Possible unintended interpolation of $\ in regex at - line 5.
940 ########
941 # toke.c
942 use warnings 'syntax' ;
943 my $a = "\o";
944 my $a = "\o{";
945 my $a = "\o{}";
946 no warnings 'syntax' ;
947 my $a = "\o";
948 my $a = "\o{";
949 my $a = "\o{}";
950 EXPECT
951 Missing braces on \o{} at - line 3, within string
952 Missing right brace on \o{ at - line 4, within string
953 Number with no digits at - line 5, within string
954 BEGIN not safe after errors--compilation aborted at - line 6.
955 ########
956 # toke.c
957 use warnings 'digit' ;
958 my $a = "\o{1238456}";
959 no warnings 'digit' ;
960 my $a = "\o{1238456}";
961 EXPECT
962 Non-octal character '8'.  Resolved as "\o{123}" at - line 3.
963 ########
964 # toke.c
965 use warnings;
966 my $a = "foo";
967 print $a =~ ?f? ? "yes\n" : "no\n" foreach 0..2;
968 EXPECT
969 Use of ?PATTERN? without explicit operator is deprecated at - line 4.
970 yes
971 no
972 no
973 ########
974 # toke.c
975 use warnings;
976 my $a = "\c{ack}";
977 $a = "\c,";
978 $a = "\c`";
979 no warnings 'syntax';
980 $a = "\c{ack}";
981 $a = "\c,";
982 $a = "\c`";
983 no warnings 'deprecated';
984 EXPECT
985 "\c{" is deprecated and is more clearly written as ";" at - line 3.
986 "\c," is more clearly written simply as "l" at - line 4.
987 "\c`" is more clearly written simply as "\ " at - line 5.
988 "\c{" is deprecated and is more clearly written as ";" at - line 7.
989 ########
990 # toke.c
991 use warnings 'syntax' ;
992 my $a = qr/foo/du;
993 $a = qr/foo/lai;
994 $a = qr/foo/lil;
995 $a = qr/foo/aia;
996 $a = qr/foo/aaia;
997 no warnings 'syntax' ;
998 my $a = qr/foo/du;
999 EXPECT
1000 Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= "
1001 Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= "
1002 Regexp modifier "/l" may not appear twice at - line 5, near "= "
1003 Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= "
1004 BEGIN not safe after errors--compilation aborted at - line 8.
1005 ########
1006 # toke.c
1007 # [perl #4362]
1008 eval "print q\xabfoo";
1009 print "ok\n" if
1010     $@ =~ /Can't find string terminator "\xab" anywhere before EOF/;
1011 EXPECT
1012 ok