64-bit work. Now 32-bit platforms get a 100% make test
[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
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 warning '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 Use of \\x{} without utf8 declaration
93 $_ = " \x{123} " ;
94
95
96 \x%.*s will produce malformed UTF-8 character; use \x{%.*s} for that
97 use utf8 ;
98 $_ = "\xffe"
99
0453d815 100 Mandatory Warnings
101 ------------------
102 Use of "%s" without parentheses is ambiguous [check_uni]
103 rand + 4
104
105 Ambiguous use of -%s resolved as -&%s() [yylex]
106 sub fred {} ; - fred ;
107
108 Precedence problem: open %.*s should be open(%.*s) [yylex]
109 open FOO || die;
110
111 Operator or semicolon missing before %c%s [yylex]
112 Ambiguous use of %c resolved as operator %c
113 *foo *foo
114
599cee73 115__END__
116# toke.c
117use warning 'deprecated' ;
1181 if $a EQ $b ;
1191 if $a NE $b ;
1201 if $a GT $b ;
1211 if $a LT $b ;
1221 if $a GE $b ;
1231 if $a LE $b ;
0453d815 124no warning 'deprecated' ;
1251 if $a EQ $b ;
1261 if $a NE $b ;
1271 if $a GT $b ;
1281 if $a LT $b ;
1291 if $a GE $b ;
1301 if $a LE $b ;
599cee73 131EXPECT
132Use of EQ is deprecated at - line 3.
133Use of NE is deprecated at - line 4.
134Use of GT is deprecated at - line 5.
135Use of LT is deprecated at - line 6.
136Use of GE is deprecated at - line 7.
137Use of LE is deprecated at - line 8.
138########
139# toke.c
140use warning 'deprecated' ;
141format STDOUT =
142@<<< @||| @>>> @>>>
143$a $b "abc" 'def'
144.
0453d815 145no warning 'deprecated' ;
146format STDOUT =
147@<<< @||| @>>> @>>>
148$a $b "abc" 'def'
149.
599cee73 150EXPECT
151Use of comma-less variable list is deprecated at - line 5.
152Use of comma-less variable list is deprecated at - line 5.
153Use of comma-less variable list is deprecated at - line 5.
599cee73 154########
155# toke.c
156use warning 'deprecated' ;
157$a = <<;
158
0453d815 159no warning 'deprecated' ;
160$a = <<;
161
599cee73 162EXPECT
163Use of bare << to mean <<"" is deprecated at - line 3.
164########
165# toke.c
166use warning 'syntax' ;
167s/(abc)/\1/;
0453d815 168no warning 'syntax' ;
169s/(abc)/\1/;
599cee73 170EXPECT
171\1 better written as $1 at - line 3.
172########
173# toke.c
174use warning 'semicolon' ;
175$a = 1
176&time ;
0453d815 177no warning 'semicolon' ;
178$a = 1
179&time ;
599cee73 180EXPECT
181Semicolon seems to be missing at - line 3.
182########
183# toke.c
e4050d25 184BEGIN {
185 # Scalars leaked: due to syntax errors
186 $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
187}
599cee73 188use warning 'syntax' ;
189my $a =+ 2 ;
190$a =- 2 ;
191$a =* 2 ;
192$a =% 2 ;
193$a =& 2 ;
194$a =. 2 ;
195$a =^ 2 ;
196$a =| 2 ;
197$a =< 2 ;
198$a =/ 2 ;
199EXPECT
e4050d25 200Reversed += operator at - line 7.
201Reversed -= operator at - line 8.
202Reversed *= operator at - line 9.
203Reversed %= operator at - line 10.
204Reversed &= operator at - line 11.
205Reversed .= operator at - line 12.
206syntax error at - line 12, near "=."
207Reversed ^= operator at - line 13.
208syntax error at - line 13, near "=^"
209Reversed |= operator at - line 14.
210syntax error at - line 14, near "=|"
211Reversed <= operator at - line 15.
212Unterminated <> operator at - line 15.
599cee73 213########
214# toke.c
0453d815 215BEGIN {
216 # Scalars leaked: due to syntax errors
217 $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
218}
219no warning 'syntax' ;
220my $a =+ 2 ;
221$a =- 2 ;
222$a =* 2 ;
223$a =% 2 ;
224$a =& 2 ;
225$a =. 2 ;
226$a =^ 2 ;
227$a =| 2 ;
228$a =< 2 ;
229$a =/ 2 ;
230EXPECT
231syntax error at - line 12, near "=."
232syntax error at - line 13, near "=^"
233syntax error at - line 14, near "=|"
234Unterminated <> operator at - line 15.
235########
236# toke.c
599cee73 237use warning 'syntax' ;
238my $a = $a[1,2] ;
0453d815 239no warning 'syntax' ;
240my $a = $a[1,2] ;
599cee73 241EXPECT
242Multidimensional syntax $a[1,2] not supported at - line 3.
243########
244# toke.c
245use warning 'syntax' ;
246sub fred {} ; $SIG{TERM} = fred;
0453d815 247no warning 'syntax' ;
248$SIG{TERM} = fred;
599cee73 249EXPECT
250You need to quote "fred" at - line 3.
251########
252# toke.c
253use warning 'syntax' ;
254@a[3] = 2;
255@a{3} = 2;
0453d815 256no warning 'syntax' ;
257@a[3] = 2;
258@a{3} = 2;
599cee73 259EXPECT
260Scalar value @a[3] better written as $a[3] at - line 3.
261Scalar value @a{3} better written as $a{3} at - line 4.
262########
263# toke.c
264use warning 'syntax' ;
265$_ = "ab" ;
266s/(ab)/\1/e;
0453d815 267no warning 'syntax' ;
268$_ = "ab" ;
269s/(ab)/\1/e;
599cee73 270EXPECT
271Can't use \1 to mean $1 in expression at - line 4.
272########
273# toke.c
274use warning 'reserved' ;
275$a = abc;
0453d815 276no warning 'reserved' ;
277$a = abc;
599cee73 278EXPECT
279Unquoted string "abc" may clash with future reserved word at - line 3.
280########
281# toke.c
282use warning 'octal' ;
283chmod 3;
0453d815 284no warning 'octal' ;
285chmod 3;
599cee73 286EXPECT
287chmod: mode argument is missing initial 0 at - line 3, at end of line
288########
289# toke.c
290use warning 'syntax' ;
291@a = qw(a, b, c) ;
0453d815 292no warning 'syntax' ;
293@a = qw(a, b, c) ;
599cee73 294EXPECT
295Possible attempt to separate words with commas at - line 3.
296########
297# toke.c
298use warning 'syntax' ;
299@a = qw(a b #) ;
0453d815 300no warning 'syntax' ;
301@a = qw(a b #) ;
599cee73 302EXPECT
303Possible attempt to put comments in qw() list at - line 3.
304########
305# toke.c
306use warning 'octal' ;
307umask 3;
0453d815 308no warning 'octal' ;
309umask 3;
599cee73 310EXPECT
311umask: argument is missing initial 0 at - line 3, at end of line
312########
313# toke.c
314use warning 'syntax' ;
315print ("")
316EXPECT
317print (...) interpreted as function at - line 3.
318########
319# toke.c
0453d815 320no warning 'syntax' ;
321print ("")
322EXPECT
323
324########
325# toke.c
599cee73 326use warning 'syntax' ;
327printf ("")
328EXPECT
329printf (...) interpreted as function at - line 3.
330########
331# toke.c
0453d815 332no warning 'syntax' ;
333printf ("")
334EXPECT
335
336########
337# toke.c
599cee73 338use warning 'syntax' ;
339sort ("")
340EXPECT
341sort (...) interpreted as function at - line 3.
342########
343# toke.c
0453d815 344no warning 'syntax' ;
345sort ("")
346EXPECT
347
348########
349# toke.c
599cee73 350use warning 'ambiguous' ;
351$a = ${time[2]};
0453d815 352no warning 'ambiguous' ;
353$a = ${time[2]};
599cee73 354EXPECT
355Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
356########
357# toke.c
358use warning 'ambiguous' ;
359$a = ${time{2}};
360EXPECT
361Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
362########
363# toke.c
0453d815 364no warning 'ambiguous' ;
365$a = ${time{2}};
366EXPECT
367
368########
369# toke.c
599cee73 370use warning 'ambiguous' ;
371$a = ${time} ;
0453d815 372no warning 'ambiguous' ;
373$a = ${time} ;
599cee73 374EXPECT
375Ambiguous use of ${time} resolved to $time at - line 3.
376########
377# toke.c
378use warning 'ambiguous' ;
379sub fred {}
380$a = ${fred} ;
0453d815 381no warning 'ambiguous' ;
382$a = ${fred} ;
599cee73 383EXPECT
384Ambiguous use of ${fred} resolved to $fred at - line 4.
385########
386# toke.c
387use warning 'syntax' ;
388$a = 1_2;
389$a = 1_2345_6;
0453d815 390no warning 'syntax' ;
391$a = 1_2;
392$a = 1_2345_6;
599cee73 393EXPECT
394Misplaced _ in number at - line 3.
395Misplaced _ in number at - line 4.
396Misplaced _ in number at - line 4.
397########
398# toke.c
399use warning 'unsafe' ;
60e6418e 400#line 25 "bar"
599cee73 401$a = FRED:: ;
0453d815 402no warning 'unsafe' ;
403#line 25 "bar"
404$a = FRED:: ;
599cee73 405EXPECT
60e6418e 406Bareword "FRED::" refers to nonexistent package at bar line 25.
599cee73 407########
408# toke.c
409use warning 'ambiguous' ;
410sub time {}
0453d815 411my $a = time() ;
412no warning 'ambiguous' ;
413my $b = time() ;
599cee73 414EXPECT
415Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
416########
417# toke.c
418use warning 'utf8' ;
60e6418e 419eval <<'EOE';
420{
421#line 30 "foo"
422 $_ = " \x{123} " ;
423}
424EOE
599cee73 425EXPECT
60e6418e 426Use of \x{} without utf8 declaration at foo line 30.
599cee73 427########
428# toke.c
0453d815 429no warning 'utf8' ;
430eval <<'EOE';
431{
432#line 30 "foo"
433 $_ = " \x{123} " ;
434}
435EOE
436EXPECT
437
438########
439# toke.c
599cee73 440use warning 'utf8' ;
441use utf8 ;
442$_ = " \xffe " ;
0453d815 443no warning 'utf8' ;
444$_ = " \xffe " ;
599cee73 445EXPECT
446\xff will produce malformed UTF-8 character; use \x{ff} for that at - line 4.
0453d815 447########
448# toke.c
449my $a = rand + 4 ;
450EXPECT
451Warning: Use of "rand" without parens is ambiguous at - line 2.
452########
453# toke.c
454$^W = 0 ;
455my $a = rand + 4 ;
456{
457 no warning 'ambiguous' ;
458 $a = rand + 4 ;
459 use warning 'ambiguous' ;
460 $a = rand + 4 ;
461}
462$a = rand + 4 ;
463EXPECT
464Warning: Use of "rand" without parens is ambiguous at - line 3.
465Warning: Use of "rand" without parens is ambiguous at - line 8.
466Warning: Use of "rand" without parens is ambiguous at - line 10.
467########
468# toke.c
469sub fred {};
470-fred ;
471EXPECT
472Ambiguous use of -fred resolved as -&fred() at - line 3.
473########
474# toke.c
475$^W = 0 ;
476sub fred {} ;
477-fred ;
478{
479 no warning 'ambiguous' ;
480 -fred ;
481 use warning 'ambiguous' ;
482 -fred ;
483}
484-fred ;
485EXPECT
486Ambiguous use of -fred resolved as -&fred() at - line 4.
487Ambiguous use of -fred resolved as -&fred() at - line 9.
488Ambiguous use of -fred resolved as -&fred() at - line 11.
489########
490# toke.c
491open FOO || time;
492EXPECT
493Precedence problem: open FOO should be open(FOO) at - line 2.
494########
495# toke.c
496$^W = 0 ;
497open FOO || time;
498{
499 no warning 'ambiguous' ;
500 open FOO || time;
501 use warning 'ambiguous' ;
502 open FOO || time;
503}
504open FOO || time;
505EXPECT
506Precedence problem: open FOO should be open(FOO) at - line 3.
507Precedence problem: open FOO should be open(FOO) at - line 8.
508Precedence problem: open FOO should be open(FOO) at - line 10.
509########
510# toke.c
511$^W = 0 ;
512*foo *foo ;
513{
514 no warning 'ambiguous' ;
515 *foo *foo ;
516 use warning 'ambiguous' ;
517 *foo *foo ;
518}
519*foo *foo ;
520EXPECT
521Operator or semicolon missing before *foo at - line 3.
522Ambiguous use of * resolved as operator * at - line 3.
523Operator or semicolon missing before *foo at - line 8.
524Ambiguous use of * resolved as operator * at - line 8.
525Operator or semicolon missing before *foo at - line 10.
526Ambiguous use of * resolved as operator * at - line 10.