Use setproctitle() if available to modify $0.
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / toke
CommitLineData
599cee73 1toke.c AOK
2
3 we seem to have lost a few ambiguous warnings!!
4
5
599cee73 6 $a = <<;
7 Use of comma-less variable list is deprecated
8 (called 3 times via depcom)
9
10 \1 better written as $1
4438c4b7 11 use warnings 'syntax' ;
599cee73 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
073ca4f1 49 chmod() mode argument is missing initial 0
599cee73 50 chmod 3;
51
52 Possible attempt to separate words with commas
53 @a = qw(a, b, c) ;
54
55 Possible attempt to put comments in qw() list
56 @a = qw(a b # c) ;
57
58 umask: argument is missing initial 0
59 umask 3;
60
61 %s (...) interpreted as function
62 print ("")
63 printf ("")
64 sort ("")
65
66 Ambiguous use of %c{%s%s} resolved to %c%s%s
67 $a = ${time[2]}
68 $a = ${time{2}}
69
70
71 Ambiguous use of %c{%s} resolved to %c%s
72 $a = ${time}
73 sub fred {} $a = ${fred}
74
75 Misplaced _ in number
76 $a = 1_2;
77 $a = 1_2345_6;
78
79 Bareword \"%s\" refers to nonexistent package
80 $a = FRED:: ;
81
82 Ambiguous call resolved as CORE::%s(), qualify as such or use &
83 sub time {}
84 my $a = time()
85
767a6a26 86 Unrecognized escape \\%c passed through
87 $a = "\m" ;
88
89 %s number > %s non-portable
90 my $a = 0b011111111111111111111111111111110 ;
91 $a = 0b011111111111111111111111111111111 ;
92 $a = 0b111111111111111111111111111111111 ;
93 $a = 0x0fffffffe ;
94 $a = 0x0ffffffff ;
95 $a = 0x1ffffffff ;
96 $a = 0037777777776 ;
97 $a = 0037777777777 ;
98 $a = 0047777777777 ;
99
100 Integer overflow in binary number
101 my $a = 0b011111111111111111111111111111110 ;
102 $a = 0b011111111111111111111111111111111 ;
103 $a = 0b111111111111111111111111111111111 ;
104 $a = 0x0fffffffe ;
105 $a = 0x0ffffffff ;
106 $a = 0x1ffffffff ;
107 $a = 0037777777776 ;
108 $a = 0037777777777 ;
109 $a = 0047777777777 ;
599cee73 110
0453d815 111 Mandatory Warnings
112 ------------------
113 Use of "%s" without parentheses is ambiguous [check_uni]
114 rand + 4
115
116 Ambiguous use of -%s resolved as -&%s() [yylex]
117 sub fred {} ; - fred ;
118
119 Precedence problem: open %.*s should be open(%.*s) [yylex]
120 open FOO || die;
121
122 Operator or semicolon missing before %c%s [yylex]
123 Ambiguous use of %c resolved as operator %c
124 *foo *foo
125
599cee73 126__END__
127# toke.c
599cee73 128########
129# toke.c
4438c4b7 130use warnings 'deprecated' ;
599cee73 131format STDOUT =
132@<<< @||| @>>> @>>>
133$a $b "abc" 'def'
134.
4438c4b7 135no warnings 'deprecated' ;
0453d815 136format STDOUT =
137@<<< @||| @>>> @>>>
138$a $b "abc" 'def'
139.
599cee73 140EXPECT
141Use of comma-less variable list is deprecated at - line 5.
142Use of comma-less variable list is deprecated at - line 5.
143Use of comma-less variable list is deprecated at - line 5.
599cee73 144########
145# toke.c
4438c4b7 146use warnings 'deprecated' ;
599cee73 147$a = <<;
148
4438c4b7 149no warnings 'deprecated' ;
0453d815 150$a = <<;
151
599cee73 152EXPECT
153Use of bare << to mean <<"" is deprecated at - line 3.
154########
155# toke.c
4438c4b7 156use warnings 'syntax' ;
599cee73 157s/(abc)/\1/;
4438c4b7 158no warnings 'syntax' ;
0453d815 159s/(abc)/\1/;
599cee73 160EXPECT
161\1 better written as $1 at - line 3.
162########
163# toke.c
4438c4b7 164use warnings 'semicolon' ;
599cee73 165$a = 1
166&time ;
4438c4b7 167no warnings 'semicolon' ;
0453d815 168$a = 1
169&time ;
599cee73 170EXPECT
171Semicolon seems to be missing at - line 3.
172########
173# toke.c
e4050d25 174BEGIN {
175 # Scalars leaked: due to syntax errors
176 $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
177}
4438c4b7 178use warnings 'syntax' ;
599cee73 179my $a =+ 2 ;
180$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 ;
189EXPECT
e4050d25 190Reversed += operator at - line 7.
191Reversed -= operator at - line 8.
192Reversed *= operator at - line 9.
193Reversed %= operator at - line 10.
194Reversed &= operator at - line 11.
195Reversed .= operator at - line 12.
e4050d25 196Reversed ^= operator at - line 13.
e4050d25 197Reversed |= operator at - line 14.
e4050d25 198Reversed <= operator at - line 15.
24944567 199syntax error at - line 12, near "=."
200syntax error at - line 13, near "=^"
201syntax error at - line 14, near "=|"
e4050d25 202Unterminated <> operator at - line 15.
599cee73 203########
204# toke.c
0453d815 205BEGIN {
206 # Scalars leaked: due to syntax errors
207 $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
208}
4438c4b7 209no warnings 'syntax' ;
0453d815 210my $a =+ 2 ;
211$a =- 2 ;
212$a =* 2 ;
213$a =% 2 ;
214$a =& 2 ;
215$a =. 2 ;
216$a =^ 2 ;
217$a =| 2 ;
218$a =< 2 ;
219$a =/ 2 ;
220EXPECT
221syntax error at - line 12, near "=."
222syntax error at - line 13, near "=^"
223syntax error at - line 14, near "=|"
224Unterminated <> operator at - line 15.
225########
226# toke.c
4438c4b7 227use warnings 'syntax' ;
599cee73 228my $a = $a[1,2] ;
4438c4b7 229no warnings 'syntax' ;
0453d815 230my $a = $a[1,2] ;
599cee73 231EXPECT
232Multidimensional syntax $a[1,2] not supported at - line 3.
233########
234# toke.c
4438c4b7 235use warnings 'syntax' ;
599cee73 236sub fred {} ; $SIG{TERM} = fred;
4438c4b7 237no warnings 'syntax' ;
0453d815 238$SIG{TERM} = fred;
599cee73 239EXPECT
240You need to quote "fred" at - line 3.
241########
242# toke.c
4438c4b7 243use warnings 'syntax' ;
599cee73 244@a[3] = 2;
245@a{3} = 2;
4438c4b7 246no warnings 'syntax' ;
0453d815 247@a[3] = 2;
248@a{3} = 2;
599cee73 249EXPECT
250Scalar value @a[3] better written as $a[3] at - line 3.
251Scalar value @a{3} better written as $a{3} at - line 4.
252########
253# toke.c
4438c4b7 254use warnings 'syntax' ;
599cee73 255$_ = "ab" ;
256s/(ab)/\1/e;
4438c4b7 257no warnings 'syntax' ;
0453d815 258$_ = "ab" ;
259s/(ab)/\1/e;
599cee73 260EXPECT
261Can't use \1 to mean $1 in expression at - line 4.
262########
263# toke.c
4438c4b7 264use warnings 'reserved' ;
599cee73 265$a = abc;
1c3923b3 266$a = { def
267
268=> 1 };
4438c4b7 269no warnings 'reserved' ;
0453d815 270$a = abc;
599cee73 271EXPECT
272Unquoted string "abc" may clash with future reserved word at - line 3.
273########
274# toke.c
e476b1b5 275use warnings 'chmod' ;
599cee73 276chmod 3;
e476b1b5 277no warnings 'chmod' ;
0453d815 278chmod 3;
599cee73 279EXPECT
073ca4f1 280chmod() mode argument is missing initial 0 at - line 3.
599cee73 281########
282# toke.c
e476b1b5 283use warnings 'qw' ;
599cee73 284@a = qw(a, b, c) ;
e476b1b5 285no warnings 'qw' ;
0453d815 286@a = qw(a, b, c) ;
599cee73 287EXPECT
288Possible attempt to separate words with commas at - line 3.
289########
290# toke.c
e476b1b5 291use warnings 'qw' ;
599cee73 292@a = qw(a b #) ;
e476b1b5 293no warnings 'qw' ;
0453d815 294@a = qw(a b #) ;
599cee73 295EXPECT
296Possible attempt to put comments in qw() list at - line 3.
297########
298# toke.c
e476b1b5 299use warnings 'umask' ;
599cee73 300umask 3;
e476b1b5 301no warnings 'umask' ;
0453d815 302umask 3;
599cee73 303EXPECT
4438c4b7 304umask: argument is missing initial 0 at - line 3.
599cee73 305########
306# toke.c
4438c4b7 307use warnings 'syntax' ;
599cee73 308print ("")
309EXPECT
310print (...) interpreted as function at - line 3.
311########
312# toke.c
4438c4b7 313no warnings 'syntax' ;
0453d815 314print ("")
315EXPECT
316
317########
318# toke.c
4438c4b7 319use warnings 'syntax' ;
599cee73 320printf ("")
321EXPECT
322printf (...) interpreted as function at - line 3.
323########
324# toke.c
4438c4b7 325no warnings 'syntax' ;
0453d815 326printf ("")
327EXPECT
328
329########
330# toke.c
4438c4b7 331use warnings 'syntax' ;
599cee73 332sort ("")
333EXPECT
334sort (...) interpreted as function at - line 3.
335########
336# toke.c
4438c4b7 337no warnings 'syntax' ;
0453d815 338sort ("")
339EXPECT
340
341########
342# toke.c
4438c4b7 343use warnings 'ambiguous' ;
599cee73 344$a = ${time[2]};
4438c4b7 345no warnings 'ambiguous' ;
0453d815 346$a = ${time[2]};
599cee73 347EXPECT
348Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
349########
350# toke.c
4438c4b7 351use warnings 'ambiguous' ;
599cee73 352$a = ${time{2}};
353EXPECT
354Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
355########
356# toke.c
4438c4b7 357no warnings 'ambiguous' ;
0453d815 358$a = ${time{2}};
359EXPECT
360
361########
362# toke.c
4438c4b7 363use warnings 'ambiguous' ;
599cee73 364$a = ${time} ;
4438c4b7 365no warnings 'ambiguous' ;
0453d815 366$a = ${time} ;
599cee73 367EXPECT
368Ambiguous use of ${time} resolved to $time at - line 3.
369########
370# toke.c
4438c4b7 371use warnings 'ambiguous' ;
599cee73 372sub fred {}
373$a = ${fred} ;
4438c4b7 374no warnings 'ambiguous' ;
0453d815 375$a = ${fred} ;
599cee73 376EXPECT
377Ambiguous use of ${fred} resolved to $fred at - line 4.
378########
379# toke.c
4438c4b7 380use warnings 'syntax' ;
599cee73 381$a = 1_2;
382$a = 1_2345_6;
4438c4b7 383no warnings 'syntax' ;
0453d815 384$a = 1_2;
385$a = 1_2345_6;
599cee73 386EXPECT
387Misplaced _ in number at - line 3.
388Misplaced _ in number at - line 4.
389Misplaced _ in number at - line 4.
390########
391# toke.c
e476b1b5 392use warnings 'bareword' ;
60e6418e 393#line 25 "bar"
599cee73 394$a = FRED:: ;
e476b1b5 395no warnings 'bareword' ;
0453d815 396#line 25 "bar"
397$a = FRED:: ;
599cee73 398EXPECT
60e6418e 399Bareword "FRED::" refers to nonexistent package at bar line 25.
599cee73 400########
401# toke.c
4438c4b7 402use warnings 'ambiguous' ;
599cee73 403sub time {}
0453d815 404my $a = time() ;
4438c4b7 405no warnings 'ambiguous' ;
0453d815 406my $b = time() ;
599cee73 407EXPECT
408Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
409########
410# toke.c
26d16222 411use warnings ;
0453d815 412eval <<'EOE';
df0deb90 413# line 30 "foo"
414warn "yelp";
0453d815 415{
0453d815 416 $_ = " \x{123} " ;
417}
418EOE
419EXPECT
df0deb90 420yelp at foo line 30.
0453d815 421########
422# toke.c
0453d815 423my $a = rand + 4 ;
424EXPECT
425Warning: Use of "rand" without parens is ambiguous at - line 2.
426########
427# toke.c
428$^W = 0 ;
429my $a = rand + 4 ;
430{
4438c4b7 431 no warnings 'ambiguous' ;
0453d815 432 $a = rand + 4 ;
4438c4b7 433 use warnings 'ambiguous' ;
0453d815 434 $a = rand + 4 ;
435}
436$a = rand + 4 ;
437EXPECT
438Warning: Use of "rand" without parens is ambiguous at - line 3.
439Warning: Use of "rand" without parens is ambiguous at - line 8.
440Warning: Use of "rand" without parens is ambiguous at - line 10.
441########
442# toke.c
443sub fred {};
444-fred ;
445EXPECT
446Ambiguous use of -fred resolved as -&fred() at - line 3.
447########
448# toke.c
449$^W = 0 ;
450sub fred {} ;
451-fred ;
452{
4438c4b7 453 no warnings 'ambiguous' ;
0453d815 454 -fred ;
4438c4b7 455 use warnings 'ambiguous' ;
0453d815 456 -fred ;
457}
458-fred ;
459EXPECT
460Ambiguous use of -fred resolved as -&fred() at - line 4.
461Ambiguous use of -fred resolved as -&fred() at - line 9.
462Ambiguous use of -fred resolved as -&fred() at - line 11.
463########
464# toke.c
465open FOO || time;
466EXPECT
467Precedence problem: open FOO should be open(FOO) at - line 2.
468########
469# toke.c
470$^W = 0 ;
471open FOO || time;
472{
e476b1b5 473 no warnings 'precedence' ;
0453d815 474 open FOO || time;
e476b1b5 475 use warnings 'precedence' ;
0453d815 476 open FOO || time;
477}
478open FOO || time;
479EXPECT
480Precedence problem: open FOO should be open(FOO) at - line 3.
481Precedence problem: open FOO should be open(FOO) at - line 8.
482Precedence problem: open FOO should be open(FOO) at - line 10.
483########
484# toke.c
485$^W = 0 ;
486*foo *foo ;
487{
4438c4b7 488 no warnings 'ambiguous' ;
0453d815 489 *foo *foo ;
4438c4b7 490 use warnings 'ambiguous' ;
0453d815 491 *foo *foo ;
492}
493*foo *foo ;
494EXPECT
495Operator or semicolon missing before *foo at - line 3.
496Ambiguous use of * resolved as operator * at - line 3.
497Operator or semicolon missing before *foo at - line 8.
498Ambiguous use of * resolved as operator * at - line 8.
499Operator or semicolon missing before *foo at - line 10.
500Ambiguous use of * resolved as operator * at - line 10.
767a6a26 501########
502# toke.c
e476b1b5 503use warnings 'misc' ;
767a6a26 504my $a = "\m" ;
e476b1b5 505no warnings 'misc' ;
767a6a26 506$a = "\m" ;
507EXPECT
508Unrecognized escape \m passed through at - line 3.
509########
510# toke.c
511use warnings 'portable' ;
512my $a = 0b011111111111111111111111111111110 ;
513 $a = 0b011111111111111111111111111111111 ;
514 $a = 0b111111111111111111111111111111111 ;
515 $a = 0x0fffffffe ;
516 $a = 0x0ffffffff ;
517 $a = 0x1ffffffff ;
518 $a = 0037777777776 ;
519 $a = 0037777777777 ;
520 $a = 0047777777777 ;
521no warnings 'portable' ;
522 $a = 0b011111111111111111111111111111110 ;
523 $a = 0b011111111111111111111111111111111 ;
524 $a = 0b111111111111111111111111111111111 ;
525 $a = 0x0fffffffe ;
526 $a = 0x0ffffffff ;
527 $a = 0x1ffffffff ;
528 $a = 0037777777776 ;
529 $a = 0037777777777 ;
530 $a = 0047777777777 ;
531EXPECT
532Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
533Hexadecimal number > 0xffffffff non-portable at - line 8.
534Octal number > 037777777777 non-portable at - line 11.
535########
536# toke.c
537use warnings 'overflow' ;
538my $a = 0b011111111111111111111111111111110 ;
539 $a = 0b011111111111111111111111111111111 ;
15041a67 540 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26 541 $a = 0x0fffffffe ;
542 $a = 0x0ffffffff ;
15041a67 543 $a = 0x10000000000000000 ;
767a6a26 544 $a = 0037777777776 ;
545 $a = 0037777777777 ;
15041a67 546 $a = 002000000000000000000000;
767a6a26 547no warnings 'overflow' ;
548 $a = 0b011111111111111111111111111111110 ;
549 $a = 0b011111111111111111111111111111111 ;
15041a67 550 $a = 0b10000000000000000000000000000000000000000000000000000000000000000 ;
767a6a26 551 $a = 0x0fffffffe ;
552 $a = 0x0ffffffff ;
15041a67 553 $a = 0x10000000000000000 ;
767a6a26 554 $a = 0037777777776 ;
555 $a = 0037777777777 ;
15041a67 556 $a = 002000000000000000000000;
767a6a26 557EXPECT
558Integer overflow in binary number at - line 5.
559Integer overflow in hexadecimal number at - line 8.
560Integer overflow in octal number at - line 11.
8593bda5 561########
562# toke.c
563use warnings 'ambiguous';
564"@mjd_previously_unused_array";
565no warnings 'ambiguous';
566"@mjd_previously_unused_array";
567EXPECT
568Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.