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