xref: /openbsd/gnu/usr.bin/perl/t/lib/warnings/toke (revision 4bdff4be)
1toke.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__
132use utf8;
133use open qw( :utf8 :std );
134use warnings;
135eval "sub fòò (@\$\0) {}";
136EXPECT
137Prototype after '@' for main::fòò : @$\0 at (eval 1) line 1.
138Illegal character in prototype for main::fòò : @$\0 at (eval 1) line 1.
139########
140use utf8;
141use open qw( :utf8 :std );
142use warnings;
143eval "sub foo (@\0) {}";
144eval "sub foo2 :prototype(@\0) {}";
145EXPECT
146Prototype after '@' for main::foo : @\0 at (eval 1) line 1.
147Illegal character in prototype for main::foo : @\0 at (eval 1) line 1.
148Prototype after '@' for main::foo2 : @\x{0} at (eval 2) line 1.
149Illegal character in prototype for main::foo2 : @\x{0} at (eval 2) line 1.
150########
151BEGIN {
152    if (ord('A') == 193) {
153        print "SKIPPED\n# Different results on EBCDIC";
154        exit 0;
155    }
156}
157use utf8;
158use open qw( :utf8 :std );
159use warnings;
160BEGIN { $::{"foo"} = "\@\$\0L\351on" }
161BEGIN { eval "sub foo (@\$\0L\x{c3}\x{a9}on) {}"; }
162EXPECT
163Prototype after '@' for main::foo : @$\x{0}L... at (eval 1) line 1.
164Illegal character in prototype for main::foo : @$\x{0}L... at (eval 1) line 1.
165########
166use utf8;
167use open qw( :utf8 :std );
168use warnings;
169BEGIN { eval "sub foo (@\0) {}"; }
170EXPECT
171Prototype after '@' for main::foo : @\0 at (eval 1) line 1.
172Illegal character in prototype for main::foo : @\0 at (eval 1) line 1.
173########
174use warnings;
175eval "sub foo (@\xAB) {}";
176EXPECT
177Prototype after '@' for main::foo : @\x{ab} at (eval 1) line 1.
178Illegal character in prototype for main::foo : @\x{ab} at (eval 1) line 1.
179########
180use utf8;
181use open qw( :utf8 :std );
182use warnings;
183BEGIN { eval "sub foo (@\x{30cb}) {}"; }
184EXPECT
185Prototype after '@' for main::foo : @\x{30cb} at (eval 1) line 1.
186Illegal character in prototype for main::foo : @\x{30cb} at (eval 1) line 1.
187########
188use warnings;
189sub f ([);
190sub f :prototype([)
191EXPECT
192Missing ']' in prototype for main::f : [ at - line 2.
193Missing ']' in prototype for main::f : [ at - line 3.
194########
195use warnings;
196package bar { sub bar { eval q"sub foo ([)" } }
197bar::bar
198EXPECT
199Missing ']' 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
205EXPECT
206OPTION fatal
207Unknown regexp modifier "/e" at - line 2, near "=~ "
208Unknown regexp modifier "/q" at - line 2, near "=~ "
209Unknown regexp modifier "/q" at - line 3, near "=~ "
210Execution of - aborted due to compilation errors.
211########
212# toke.c
213use utf8;
214use open qw( :utf8 :std );
215$a =~ m/$foo/eネq;
216$a =~ s/$foo/fool/seネq;
217
218EXPECT
219OPTION fatal
220Unknown regexp modifier "/e" at - line 4, near "=~ "
221Unknown regexp modifier "/ネ" at - line 4, near "=~ "
222Unknown regexp modifier "/q" at - line 4, near "=~ "
223Unknown regexp modifier "/ネ" at - line 5, near "=~ "
224Unknown regexp modifier "/q" at - line 5, near "=~ "
225Execution of - aborted due to compilation errors.
226########
227# toke.c
228use warnings 'syntax' ;
229s/(abc)/\1/;
230no warnings 'syntax' ;
231s/(abc)/\1/;
232EXPECT
233\1 better written as $1 at - line 3.
234########
235# toke.c
236use warnings 'semicolon' ;
237$a = 1
238&time ;
239no warnings 'semicolon' ;
240$a = 1
241&time ;
242EXPECT
243Semicolon seems to be missing at - line 3.
244########
245# toke.c
246use warnings 'syntax' ;
247my $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 ;
257EXPECT
258Reversed += operator at - line 3.
259Reversed -= operator at - line 4.
260Reversed *= operator at - line 5.
261Reversed %= operator at - line 6.
262Reversed &= operator at - line 7.
263Reversed .= operator at - line 8.
264Reversed ^= operator at - line 9.
265Reversed |= operator at - line 10.
266Reversed <= operator at - line 11.
267syntax error at - line 8, near "=."
268syntax error at - line 9, near "=^"
269syntax error at - line 10, near "=|"
270Unterminated <> operator at - line 11.
271########
272# toke.c
273no warnings 'syntax' ;
274my $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 ;
284EXPECT
285syntax error at - line 8, near "=."
286syntax error at - line 9, near "=^"
287syntax error at - line 10, near "=|"
288Unterminated <> operator at - line 11.
289########
290# toke.c
291use warnings 'syntax' ;
292my $a = $a[1,2] ;
293no warnings 'syntax' ;
294my $a = $a[1,2] ;
295EXPECT
296Multidimensional syntax $a[1,2] not supported at - line 3.
297########
298# toke.c
299use warnings 'syntax' ;
300sub fred {} ; $SIG{TERM} = fred;
301no warnings 'syntax' ;
302$SIG{TERM} = fred;
303EXPECT
304You need to quote "fred" at - line 3.
305########
306# toke.c
307use utf8;
308use open qw( :utf8 :std );
309use warnings 'syntax' ;
310sub frèd {} ; $SIG{TERM} = frèd;
311no warnings 'syntax' ;
312$SIG{TERM} = frèd;
313EXPECT
314You need to quote "frèd" at - line 5.
315########
316# toke.c
317use utf8;
318use open qw( :utf8 :std );
319use warnings 'syntax' ;
320sub ふれど {} ; $SIG{TERM} = ふれど;
321no warnings 'syntax' ;
322$SIG{TERM} = ふれど;
323EXPECT
324You need to quote "ふれど" at - line 5.
325########
326# toke.c
327use warnings 'syntax' ;
328$_ = "ab" ;
329s/(ab)/\1/e;
330s//\(2)/e; # should be exempt
331s/${\2}//; # same here
332()="${\2}"; # metoo
333no warnings 'syntax' ;
334$_ = "ab" ;
335s/(ab)/\1/e;
336EXPECT
337Can't use \1 to mean $1 in expression at - line 4.
338########
339# toke.c
340use warnings 'reserved' ;
341$a = abc;
342$a = { def
343
344=> 1 };
345no warnings 'reserved' ;
346$a = abc;
347EXPECT
348Unquoted string "abc" may clash with future reserved word at - line 3.
349########
350# toke.c
351use warnings 'qw' ;
352@a = qw(a, b, c) ;
353no warnings 'qw' ;
354@a = qw(a, b, c) ;
355EXPECT
356Possible attempt to separate words with commas at - line 3.
357########
358# toke.c
359use warnings 'qw' ;
360@a = qw(a b c # #) ;
361no warnings 'qw' ;
362@a = qw(a b c # #) ;
363EXPECT
364Possible attempt to put comments in qw() list at - line 3.
365########
366# toke.c
367use warnings 'qw' ;
368@a = qw(a, b, c # #) ;
369no warnings 'qw' ;
370@a = qw(a, b, c # #) ;
371EXPECT
372Possible attempt to separate words with commas at - line 3.
373Possible attempt to put comments in qw() list at - line 3.
374########
375# toke.c
376use warnings 'syntax' ;
377print ("");
378print ("") and $x = 1;
379print ("") or die;
380print ("") // die;
381print (1+2) * 3 if 0; # only this one should warn
382print (1+2) if 0;
383EXPECT
384print (...) interpreted as function at - line 7.
385########
386# toke.c
387no warnings 'syntax' ;
388print ("")
389EXPECT
390
391########
392# toke.c
393use warnings 'syntax' ;
394printf ("");
395printf ("") . '';
396EXPECT
397printf (...) interpreted as function at - line 4.
398########
399# toke.c
400no warnings 'syntax' ;
401printf ("")
402EXPECT
403
404########
405# toke.c
406use warnings 'syntax' ;
407sort ("");
408sort ("") . '';
409EXPECT
410sort (...) interpreted as function at - line 4.
411########
412# toke.c
413no warnings 'syntax' ;
414sort ("")
415EXPECT
416
417########
418use warnings 'syntax';
419@foo::bar = 1..3;
420() = "$foo'bar";
421() = "@foo'bar";
422() = "$#foo'bar";
423no warnings 'syntax' ;
424() = "$foo'bar";
425() = "@foo'bar";
426() = "$#foo'bar";
427EXPECT
428Old package separator used in string at - line 3.
429	(Did you mean "$foo\'bar" instead?)
430Old package separator used in string at - line 4.
431	(Did you mean "@foo\'bar" instead?)
432Old package separator used in string at - line 5.
433	(Did you mean "$#foo\'bar" instead?)
434########
435use warnings 'syntax'; use utf8;
436@fooл::barл = 1..3;
437() = "$fooл'barл";
438() = "@fooл'barл";
439() = "$#fooл'barл";
440no warnings 'syntax' ;
441() = "$fooл'barл";
442() = "@fooл'barл";
443() = "$#fooл'barл";
444EXPECT
445Old package separator used in string at - line 3.
446	(Did you mean "$fooл\'barл" instead?)
447Old package separator used in string at - line 4.
448	(Did you mean "@fooл\'barл" instead?)
449Old package separator used in string at - line 5.
450	(Did you mean "$#fooл\'barл" instead?)
451########
452# toke.c
453use warnings 'ambiguous' ;
454$a = ${time[2]};
455no warnings 'ambiguous' ;
456$a = ${time[2]};
457EXPECT
458Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
459########
460# toke.c
461use warnings 'ambiguous' ;
462$a = ${time{2}};
463EXPECT
464Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
465########
466# toke.c
467use warnings 'ambiguous' ;
468$a = ${
469
470    time
471        {2}
472};
473warn "after";
474EXPECT
475Ambiguous use of ${time{...}} resolved to $time{...} at - line 5.
476after at - line 8.
477########
478# toke.c
479use warnings 'ambiguous' ;
480$a = ${
481
482time[2]
483
484};
485$a = ${
486
487time
488   [2]
489
490};
491warn "after";
492EXPECT
493Ambiguous use of ${time[...]} resolved to $time[...] at - line 5.
494Ambiguous use of ${time[...]} resolved to $time[...] at - line 10.
495after at - line 14.
496########
497# toke.c
498no warnings 'ambiguous' ;
499$a = ${time{2}};
500EXPECT
501
502########
503# toke.c
504use 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
511no 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
518EXPECT
519Ambiguous use of ${time} resolved to $time at - line 3.
520Ambiguous use of @{time} resolved to @time at - line 4.
521Ambiguous use of @{time} resolved to @time at - line 5.
522Ambiguous use of %{time} resolved to %time at - line 6.
523Ambiguous use of *{time} resolved to *time at - line 7.
524Ambiguous use of &{time} resolved to &time at - line 8.
525########
526# toke.c
527use warnings 'ambiguous' ;
528$a = ${
529time
530} ;
531$a = @{
532time
533} ;
534$a = $#{
535time
536} ;
537$a = %{
538time
539} ;
540$a = *{
541time
542} ;
543$a = defined &{
544time
545
546
547} ;
548warn "last";
549EXPECT
550Ambiguous use of ${time} resolved to $time at - line 4.
551Ambiguous use of @{time} resolved to @time at - line 7.
552Ambiguous use of @{time} resolved to @time at - line 10.
553Ambiguous use of %{time} resolved to %time at - line 13.
554Ambiguous use of *{time} resolved to *time at - line 16.
555Ambiguous use of &{time} resolved to &time at - line 19.
556last at - line 23.
557########
558# toke.c
559use warnings 'ambiguous' ;
560sub fred {}
561$a = ${fred} ;
562no warnings 'ambiguous' ;
563$a = ${fred} ;
564EXPECT
565Ambiguous use of ${fred} resolved to $fred at - line 4.
566########
567# toke.c
568use 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
609no 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);
650EXPECT
651OPTIONS regex
652Misplaced _ in number at - line 6.
653Misplaced _ in number at - line 11.
654Misplaced _ in number at - line 16.
655Misplaced _ in number at - line 17.
656Misplaced _ in number at - line 20.
657Misplaced _ in number at - line 21.
658Misplaced _ in number at - line 24.
659Misplaced _ in number at - line 25.
660Misplaced _ in number at - line 28.
661Misplaced _ in number at - line 29.
662Misplaced _ in number at - line 31.
663Misplaced _ in number at - line 32.
664Misplaced _ in number at - line 33.
665Misplaced _ in number at - line 35.
666Misplaced _ in number at - line 36.
667Misplaced _ in number at - line 37.
668Misplaced _ in number at - line 39.
669Misplaced _ in number at - line 40.
670Misplaced _ in number at - line 41.
671Misplaced _ in number at - line 42.
672_123
673123
674123
675123
676123
677_123
678123
679123
680123
681-123
682-_123
683-123
684-123
685-123
686123.456
687123.456
688123.456
689123.456
690123.456
691123.456
692123.456
693123.456
694-123.456
695-123.456
696-123.456
697-123.456
698123456000000000
699123456000000000
700123456000000000
701123456000000000
702123456000000000
703123456000000000
704123456000000000
7051.23456e-0?10
7061.23456e-0?10
7071.23456e-0?10
7081.23456e-0?10
709123
71012.34
71112340000000000
712_123
713123
714123
715123
716123
717_123
718123
719123
720123
721-123
722-_123
723-123
724-123
725-123
726123.456
727123.456
728123.456
729123.456
730123.456
731123.456
732123.456
733123.456
734-123.456
735-123.456
736-123.456
737-123.456
738123456000000000
739123456000000000
740123456000000000
741123456000000000
742123456000000000
743123456000000000
744123456000000000
7451.23456e-0?10
7461.23456e-0?10
7471.23456e-0?10
7481.23456e-0?10
749123
75012.34
75112340000000000
752########
753# toke.c
754use 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 = 1.2_; print "$a\n";
760$a = 1._2; print "$a\n";
761$a = 1._; print "$a\n";
762EXPECT
763Misplaced _ in number at - line 3.
764Misplaced _ in number at - line 4.
765Misplaced _ in number at - line 5.
766Misplaced _ in number at - line 6.
767Misplaced _ in number at - line 7.
768Misplaced _ in number at - line 8.
769Misplaced _ in number at - line 9.
7701
7711
7720
7731
7741.2
7751.2
7761
777########
778# toke.c
779use warnings 'bareword' ;
780#line 25 "bar"
781$a = FRED:: ;
782no warnings 'bareword' ;
783#line 25 "bar"
784$a = FRED:: ;
785EXPECT
786Bareword "FRED::" refers to nonexistent package at bar line 25.
787########
788# toke.c
789use utf8;
790use open qw( :utf8 :std );
791use warnings 'bareword' ;
792#line 25 "bar"
793$a = FRÈD:: ;
794no warnings 'bareword' ;
795#line 25 "bar"
796$a = FRÈD:: ;
797EXPECT
798Bareword "FRÈD::" refers to nonexistent package at bar line 25.
799########
800# toke.c
801use utf8;
802use open qw( :utf8 :std );
803use warnings 'bareword' ;
804#line 25 "bar"
805$a = ϞϞϞ:: ;
806no warnings 'bareword' ;
807#line 25 "bar"
808$a = ϞϞϞ:: ;
809EXPECT
810Bareword "ϞϞϞ::" refers to nonexistent package at bar line 25.
811########
812# toke.c
813use warnings 'ambiguous' ;
814sub time {}
815my $a = time() ;
816no warnings 'ambiguous' ;
817my $b = time() ;
818EXPECT
819Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
820########
821# toke.c
822use warnings ;
823eval <<'EOE';
824#  line 30 "foo"
825warn "yelp";
826{
827  $_ = " \x{123} " ;
828}
829EOE
830EXPECT
831yelp at foo line 30.
832########
833# toke.c
834my $a = rand + 4 ;
835$a = rand *^H ;
836$a = rand $^H ;
837EXPECT
838Warning: Use of "rand" without parentheses is ambiguous at - line 2.
839########
840# toke.c
841$^W = 0 ;
842my $a = rand + 4 ;
843{
844    no warnings 'ambiguous' ;
845    $a = rand + 4 ;
846    use warnings 'ambiguous' ;
847    $a = rand + 4 ;
848}
849$a = rand + 4 ;
850EXPECT
851Warning: Use of "rand" without parentheses is ambiguous at - line 3.
852Warning: Use of "rand" without parentheses is ambiguous at - line 8.
853Warning: Use of "rand" without parentheses is ambiguous at - line 10.
854########
855# [perl #97110]
856sub myrand(;$) { }
857sub whatever($) { }
858my $a = myrand + 4 ;
859my $b = whatever + 4 ;
860EXPECT
861Warning: Use of "myrand" without parentheses is ambiguous at - line 4.
862########
863# toke.c
864use warnings "ambiguous";
865print for keys %+; # should not warn
866EXPECT
867########
868# toke.c [This does not warn any more.]
869sub fred {};
870-fred ;
871sub hank : lvalue {$_}
872--hank; # This should *not* warn [perl #77240]
873EXPECT
874########
875# toke.c [This does not warn any more.]
876$^W = 0 ;
877sub fred {} ;
878-fred ;
879{
880    no warnings 'ambiguous' ;
881    -fred ;
882    use warnings 'ambiguous' ;
883    -fred ;
884}
885-fred ;
886EXPECT
887########
888# toke.c [This does not warn any more.]
889use utf8;
890use open qw( :utf8 :std );
891sub frèd {};
892-frèd ;
893EXPECT
894########
895# toke.c [This does not warn any more.]
896$^W = 0 ;
897use utf8;
898use open qw( :utf8 :std );
899sub frèd {} ;
900-frèd ;
901{
902    no warnings 'ambiguous' ;
903    -frèd ;
904    use warnings 'ambiguous' ;
905    -frèd ;
906}
907-frèd ;
908EXPECT
909########
910# toke.c [This does not warn any more.]
911use utf8;
912use open qw( :utf8 :std );
913sub ᒍᒘᒊ {};
914-ᒍᒘᒊ ;
915EXPECT
916########
917# toke.c [This does not warn any more.]
918$^W = 0 ;
919use utf8;
920use open qw( :utf8 :std );
921sub ᒍᒘᒊ {} ;
922-ᒍᒘᒊ ;
923{
924    no warnings 'ambiguous' ;
925    -ᒍᒘᒊ ;
926    use warnings 'ambiguous' ;
927    -ᒍᒘᒊ ;
928}
929-ᒍᒘᒊ ;
930EXPECT
931########
932# toke.c
933open FOO || time;
934open local *FOO; # should be ok
935EXPECT
936Precedence problem: open FOO should be open(FOO) at - line 2.
937########
938# toke.c
939use utf8;
940use open qw( :utf8 :std );
941open FÒÒ || time;
942EXPECT
943Precedence problem: open FÒÒ should be open(FÒÒ) at - line 4.
944########
945# toke.c
946use utf8;
947use open qw( :utf8 :std );
948open ᒍOO || time;
949EXPECT
950Precedence problem: open ᒍOO should be open(ᒍOO) at - line 4.
951########
952# toke.c (and [perl #16184])
953open FOO => "<&0"; close FOO;
954EXPECT
955########
956# toke.c
957$^W = 0 ;
958open FOO || time;
959{
960    no warnings 'precedence' ;
961    open FOO || time;
962    use warnings 'precedence' ;
963    open FOO || time;
964}
965open FOO || time;
966open Foo::BAR; # this should not warn
967EXPECT
968Precedence problem: open FOO should be open(FOO) at - line 3.
969Precedence problem: open FOO should be open(FOO) at - line 8.
970Precedence problem: open FOO should be open(FOO) at - line 10.
971########
972# toke.c
973$^W = 0 ;
974use utf8;
975use open qw( :utf8 :std );
976open FÒÒ || time;
977{
978    no warnings 'precedence' ;
979    open FÒÒ || time;
980    use warnings 'precedence' ;
981    open FÒÒ || time;
982}
983open FÒÒ || time;
984EXPECT
985Precedence problem: open FÒÒ should be open(FÒÒ) at - line 5.
986Precedence problem: open FÒÒ should be open(FÒÒ) at - line 10.
987Precedence problem: open FÒÒ should be open(FÒÒ) at - line 12.
988########
989# toke.c
990use utf8;
991use open qw( :utf8 :std );
992$^W = 0 ;
993open ᒍÒÒ || time;
994{
995    no warnings 'precedence' ;
996    open ᒍÒÒ || time;
997    use warnings 'precedence' ;
998    open ᒍÒÒ || time;
999}
1000open ᒍÒÒ || time;
1001EXPECT
1002Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 5.
1003Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 10.
1004Precedence problem: open ᒍÒÒ should be open(ᒍÒÒ) at - line 12.
1005########
1006# toke.c
1007$^W = 0 ;
1008*foo *foo ;
1009{
1010    no warnings 'ambiguous' ;
1011    *foo *foo ;
1012    use warnings 'ambiguous' ;
1013    *foo *foo ;
1014}
1015*foo *foo ;
1016# These should not warn [perl #117535]:
1017foo**foo ;
1018no warnings 'deprecated';
1019sort $*foo ;
1020sort $ *foo ;
1021EXPECT
1022Operator or semicolon missing before *foo at - line 3.
1023Ambiguous use of * resolved as operator * at - line 3.
1024Operator or semicolon missing before *foo at - line 8.
1025Ambiguous use of * resolved as operator * at - line 8.
1026Operator or semicolon missing before *foo at - line 10.
1027Ambiguous use of * resolved as operator * at - line 10.
1028$* is no longer supported as of Perl 5.30 at - line 14.
1029########
1030# toke.c
1031$^W = 0 ;
1032%foo %foo ;
1033{
1034    no warnings 'ambiguous' ;
1035    %foo %foo ;
1036    use warnings 'ambiguous' ;
1037    %foo %foo ;
1038}
1039%foo %foo ;
1040# This should not produce ambiguity warnings [perl #117535]:
1041sort $%foo ;
1042sort $ %foo ;
1043EXPECT
1044Operator or semicolon missing before %foo at - line 3.
1045Ambiguous use of % resolved as operator % at - line 3.
1046Operator or semicolon missing before %foo at - line 8.
1047Ambiguous use of % resolved as operator % at - line 8.
1048Operator or semicolon missing before %foo at - line 10.
1049Ambiguous use of % resolved as operator % at - line 10.
1050Bareword found where operator expected at - line 12, near "$%foo"
1051	(Missing operator before foo?)
1052Bareword found where operator expected at - line 13, near "$ %foo"
1053	(Missing operator before foo?)
1054Illegal modulus zero at - line 3.
1055########
1056# toke.c
1057$^W = 0 ;
1058&foo &foo ;
1059{
1060    no warnings 'ambiguous' ;
1061    &foo &foo ;
1062    use warnings 'ambiguous' ;
1063    &foo &foo ;
1064}
1065&foo &foo ;
1066# These should not warn produce ambiguity warnings [perl #76910]:
1067foo&&foo ;
1068sort $&foo ;
1069sort $ &foo ;
1070EXPECT
1071Operator or semicolon missing before &foo at - line 3.
1072Ambiguous use of & resolved as operator & at - line 3.
1073Operator or semicolon missing before &foo at - line 8.
1074Ambiguous use of & resolved as operator & at - line 8.
1075Operator or semicolon missing before &foo at - line 10.
1076Ambiguous use of & resolved as operator & at - line 10.
1077Bareword found where operator expected at - line 13, near "$&foo"
1078	(Missing operator before foo?)
1079Bareword found where operator expected at - line 14, near "$ &foo"
1080	(Missing operator before foo?)
1081Undefined subroutine &main::foo called at - line 3.
1082########
1083# toke.c
1084use utf8;
1085use open qw( :utf8 :std );
1086$^W = 0 ;
1087*foo *foo ;
1088{
1089    no warnings 'ambiguous' ;
1090    *foo *foo ;
1091    use warnings 'ambiguous' ;
1092    *foo *foo ;
1093}
1094*foo *foo ;
1095EXPECT
1096Operator or semicolon missing before *foo at - line 5.
1097Ambiguous use of * resolved as operator * at - line 5.
1098Operator or semicolon missing before *foo at - line 10.
1099Ambiguous use of * resolved as operator * at - line 10.
1100Operator or semicolon missing before *foo at - line 12.
1101Ambiguous use of * resolved as operator * at - line 12.
1102########
1103# toke.c
1104use warnings 'misc' ;
1105my $a = "\m" ;
1106no warnings 'misc' ;
1107$a = "\m" ;
1108EXPECT
1109Unrecognized escape \m passed through at - line 3.
1110########
1111# toke.c
1112use warnings 'misc' ;
1113my $a = "abcd\E" ;
1114no warnings 'misc' ;
1115$a = "abcd\E" ;
1116EXPECT
1117Useless use of \E at - line 3.
1118########
1119# toke.c
1120use feature 'postderef_qq';
1121(\$_)->$*;
1122"$_->$*";
1123(\$_)->$*;
1124"$_->$*";
1125EXPECT
1126########
1127# toke.c
1128use warnings 'portable' ;
1129my $a =  0b011111111111111111111111111111110 ;
1130   $a =  0b011111111111111111111111111111111 ;
1131   $a =  0b111111111111111111111111111111111 ;
1132   $a =  0x0fffffffe ;
1133   $a =  0x0ffffffff ;
1134   $a =  0x1ffffffff ;
1135   $a =  0037777777776 ;
1136   $a =  0037777777777 ;
1137   $a =  0047777777777 ;
1138no warnings 'portable' ;
1139   $a =  0b011111111111111111111111111111110 ;
1140   $a =  0b011111111111111111111111111111111 ;
1141   $a =  0b111111111111111111111111111111111 ;
1142   $a =  0x0fffffffe ;
1143   $a =  0x0ffffffff ;
1144   $a =  0x1ffffffff ;
1145   $a =  0037777777776 ;
1146   $a =  0037777777777 ;
1147   $a =  0047777777777 ;
1148EXPECT
1149Binary number > 0b11111111111111111111111111111111 non-portable at - line 5.
1150Hexadecimal number > 0xffffffff non-portable at - line 8.
1151Octal number > 037777777777 non-portable at - line 11.
1152########
1153# toke.c
1154use warnings 'overflow' ;
1155my $a =  0b011111111111111111111111111111110 ;
1156   $a =  0b011111111111111111111111111111111 ;
1157   $a =  0b10000000000000000000000000000000000000000000000000000000000000000 ;
1158   $a =  0x0fffffffe ;
1159   $a =  0x0ffffffff ;
1160   $a =  0x10000000000000000 ;
1161   $a =  0037777777776 ;
1162   $a =  0037777777777 ;
1163   $a =  002000000000000000000000;
1164no warnings 'overflow' ;
1165   $a =  0b011111111111111111111111111111110 ;
1166   $a =  0b011111111111111111111111111111111 ;
1167   $a =  0b10000000000000000000000000000000000000000000000000000000000000000 ;
1168   $a =  0x0fffffffe ;
1169   $a =  0x0ffffffff ;
1170   $a =  0x10000000000000000 ;
1171   $a =  0037777777776 ;
1172   $a =  0037777777777 ;
1173   $a =  002000000000000000000000;
1174EXPECT
1175Integer overflow in binary number at - line 5.
1176Integer overflow in hexadecimal number at - line 8.
1177Integer overflow in octal number at - line 11.
1178########
1179# toke.c
1180use warnings 'ambiguous';
1181"@mjd_previously_unused_array";
1182no warnings 'ambiguous';
1183"@mjd_previously_unused_array2";
1184EXPECT
1185Possible unintended interpolation of @mjd_previously_unused_array in string at - line 3.
1186########
1187# toke.c
1188use utf8;
1189use open qw( :utf8 :std );
1190use warnings 'ambiguous';
1191"@mjd_previously_unused_àrray";
1192no warnings 'ambiguous';
1193"@mjd_previously_unused_àrray2";
1194EXPECT
1195Possible unintended interpolation of @mjd_previously_unused_àrray in string at - line 5.
1196########
1197# toke.c
1198use utf8;
1199use open qw( :utf8 :std );
1200use warnings 'ambiguous';
1201"@mjd_previously_unused_ぁrrぁy";
1202no warnings 'ambiguous';
1203"@mjd_previously_unused_ぁrrぁy2";
1204EXPECT
1205Possible unintended interpolation of @mjd_previously_unused_ぁrrぁy in string at - line 5.
1206########
1207-w
1208# toke.c
1209$_ = "@DB::args";
1210EXPECT
1211########
1212# toke.c
1213# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
1214use warnings 'regexp';
1215"foo" =~ /foo/c;
1216"foo" =~ /foo/cg;
1217no warnings 'regexp';
1218"foo" =~ /foo/c;
1219"foo" =~ /foo/cg;
1220EXPECT
1221Use of /c modifier is meaningless without /g at - line 4.
1222########
1223# toke.c
1224# 20020328 mjd-perl-patch+@plover.com at behest of jfriedl@yahoo.com
1225use warnings 'regexp';
1226$_ = "ab" ;
1227s/ab/ab/c;
1228s/ab/ab/cg;
1229no warnings 'regexp';
1230s/ab/ab/c;
1231s/ab/ab/cg;
1232EXPECT
1233Use of /c modifier is meaningless in s/// at - line 5.
1234Use of /c modifier is meaningless in s/// at - line 6.
1235########
1236-wa
1237# toke.c
1238# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
1239print "@F\n";
1240EXPECT
1241
1242########
1243-w
1244# toke.c
1245# 20020414 mjd-perl-patch+@plover.com # -a flag should suppress these warnings
1246print "@F\n";
1247EXPECT
1248Possible unintended interpolation of @F in string at - line 4.
1249Name "main::F" used only once: possible typo at - line 4.
1250########
1251-wa
1252# toke.c
1253# 20020414 mjd-perl-patch+@plover.com
1254EXPECT
1255
1256########
1257# toke.c
1258# 20020414 mjd-perl-patch+@plover.com
1259# In 5.7.3, this emitted "Possible unintended interpolation" warnings
1260use warnings 'ambiguous';
1261$s = "(@-)(@+)";
1262EXPECT
1263
1264########
1265# toke.c
1266# mandatory warning
1267eval q/if ($a) { } elseif ($b) { }/;
1268no warnings "syntax";
1269eval q/if ($a) { } elseif ($b) { }/;
1270EXPECT
1271elseif should be elsif at (eval 1) line 1.
1272########
1273# toke.c
1274# mandatory warning
1275eval q/5 6/;
1276no warnings "syntax";
1277eval q/5 6/;
1278EXPECT
1279Number found where operator expected at (eval 1) line 1, near "5 6"
1280	(Missing operator before  6?)
1281########
1282# toke.c
1283use warnings "syntax"; no warnings "deprecated";
1284$_ = $a = 1;
1285$a !=~  /1/;
1286$a !=~ m#1#;
1287$a !=~/1/;
1288$a !=~ y/1//;
1289$a !=~ tr/1//;
1290$a !=~ s/1//;
1291$a != ~/1/;
1292no warnings "syntax";
1293$a !=~  /1/;
1294$a !=~ m#1#;
1295$a !=~/1/;
1296$a !=~ y/1//;
1297$a !=~ tr/1//;
1298$a !=~ s/1//;
1299EXPECT
1300!=~ should be !~ at - line 4.
1301!=~ should be !~ at - line 5.
1302!=~ should be !~ at - line 6.
1303!=~ should be !~ at - line 7.
1304!=~ should be !~ at - line 8.
1305!=~ should be !~ at - line 9.
1306########
1307# toke.c
1308use warnings "syntax";
1309sub proto_after_array(@$);
1310sub proto_after_arref(\@$);
1311sub proto_after_arref2(\[@$]);
1312sub proto_after_arref3(\[@$]_);
1313sub proto_after_hash(%$);
1314sub proto_after_hashref(\%$);
1315sub proto_after_hashref2(\[%$]);
1316sub underscore_last_pos($_);
1317sub underscore2($_;$);
1318sub underscore_fail($_$); sub underscore_fail2 : prototype($_$);
1319sub underscore_after_at(@_);
1320our sub hour (@$);
1321my sub migh (@$);
1322use feature 'state';
1323state sub estate (@$);
1324package other;
1325sub hour (@$);
1326sub migh (@$);
1327sub estate (@$);
1328no warnings "syntax";
1329sub proto_after_array(@$);
1330sub proto_after_hash(%$);
1331sub underscore_fail($_$);
1332EXPECT
1333Prototype after '@' for main::proto_after_array : @$ at - line 3.
1334Prototype after '%' for main::proto_after_hash : %$ at - line 7.
1335Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12.
1336Illegal character after '_' in prototype for main::underscore_fail2 : $_$ at - line 12.
1337Prototype after '@' for main::underscore_after_at : @_ at - line 13.
1338Prototype after '@' for hour : @$ at - line 14.
1339Prototype after '@' for migh : @$ at - line 15.
1340Prototype after '@' for estate : @$ at - line 17.
1341Prototype after '@' for hour : @$ at - line 19.
1342Prototype after '@' for migh : @$ at - line 20.
1343Prototype after '@' for estate : @$ at - line 21.
1344########
1345# toke.c
1346use warnings "ambiguous";
1347"foo\nn" =~ /^foo$\n/;
1348"foo\nn" =~ /^foo${\}n/;
1349my $foo = qr/^foo$\n/;
1350my $bar = qr/^foo${\}n/;
1351no warnings "ambiguous";
1352"foo\nn" =~ /^foo$\n/;
1353"foo\nn" =~ /^foo${\}n/;
1354my $foo = qr/^foo$\n/;
1355my $bar = qr/^foo${\}n/;
1356EXPECT
1357Possible unintended interpolation of $\ in regex at - line 3.
1358Possible unintended interpolation of $\ in regex at - line 5.
1359########
1360# toke.c
1361use warnings 'syntax' ;
1362my $a = "\o";
1363my $a = "\o{";
1364my $a = "\o{}";
1365no warnings 'syntax' ;
1366my $a = "\o";
1367my $a = "\o{";
1368my $a = "\o{}";
1369EXPECT
1370Missing braces on \o{} at - line 3, within string
1371Missing right brace on \o{} at - line 4, within string
1372Empty \o{} at - line 5, within string
1373BEGIN not safe after errors--compilation aborted at - line 6.
1374########
1375# toke.c
1376use warnings 'digit' ;
1377my $a = "\o{1238456}";
1378no warnings 'digit' ;
1379my $a = "\o{1238456}";
1380EXPECT
1381Non-octal character '8' terminates \o early.  Resolved as "\o{123}" at - line 3.
1382########
1383# toke.c
1384use warnings;
1385print ref ? "yes\n" : "no\n" foreach [], ''; # ? is unambiguosly an operator
1386EXPECT
1387yes
1388no
1389########
1390# toke .c
1391use warnings;
1392$a =~ ?rand?; # ? is not a regex match
1393EXPECT
1394syntax error at - line 3, near "=~ ?"
1395Execution of - aborted due to compilation errors.
1396########
1397# toke.c
1398BEGIN {
1399    if (ord('A') == 193) {
1400        print "SKIPPED\n# result varies depending on which ebcdic platform";
1401        exit 0;
1402    }
1403}
1404use warnings;
1405$a = "\c,";
1406$a = "\c`";
1407no warnings 'syntax';
1408$a = "\c,";
1409$a = "\c`";
1410EXPECT
1411"\c," is more clearly written simply as "l" at - line 9.
1412"\c`" is more clearly written simply as "\ " at - line 10.
1413########
1414# toke.c
1415BEGIN {
1416    if (ord('A') == 193) {
1417        print "SKIPPED\n# test is ASCII-specific";
1418        exit 0;
1419    }
1420}
1421use warnings;
1422my $a = "\c{ack}";
1423EXPECT
1424OPTION fatal
1425Use ";" instead of "\c{" at - line 9, within string
1426Execution of - aborted due to compilation errors.
1427########
1428# toke.c
1429BEGIN {
1430    if (ord('A') == 65) {
1431        print "SKIPPED\n# test is EBCDIC-specific";
1432        exit 0;
1433    }
1434}
1435use warnings;
1436my $a = "\c{ack}";
1437EXPECT
1438OPTION fatal
1439Sequence "\c{" invalid at - line 9, within string
1440Execution of - aborted due to compilation errors.
1441########
1442# toke.c
1443my $a = "\câ";
1444EXPECT
1445OPTION fatal
1446Character following "\c" must be printable ASCII at - line 2, within string
1447Execution of - aborted due to compilation errors.
1448########
1449# toke.c
1450use warnings 'syntax' ;
1451my $a = qr/foo/du;
1452$a = qr/foo/lai;
1453$a = qr/foo/lil;
1454$a = qr/foo/aia;
1455$a = qr/foo/aaia;
1456no warnings 'syntax' ;
1457my $a = qr/foo/du;
1458EXPECT
1459Regexp modifiers "/d" and "/u" are mutually exclusive at - line 3, near "= "
1460Regexp modifiers "/l" and "/a" are mutually exclusive at - line 4, near "= "
1461Regexp modifier "/l" may not appear twice at - line 5, near "= "
1462Regexp modifier "/a" may appear a maximum of twice at - line 7, near "= "
1463BEGIN not safe after errors--compilation aborted at - line 8.
1464########
1465# toke.c
1466# [perl #4362]
1467eval "no warnings 'deprecated'; print q\xabfoo";
1468if ($@ =~ /Can't find string terminator "\xab" anywhere before EOF/) {
1469    print "ok\n";
1470}
1471else {
1472    print "not ok $@\n";
1473}
1474EXPECT
1475ok
1476########
1477# toke.c
1478use utf8;
1479use open qw( :utf8 :std );
1480use warnings 'ambiguous' ;
1481sub frèd {}
1482$a = ${frèd} ;
1483no warnings 'ambiguous' ;
1484$a = ${frèd} ;
1485EXPECT
1486Ambiguous use of ${frèd} resolved to $frèd at - line 6.
1487########
1488# toke.c
1489use utf8;
1490use open qw( :utf8 :std );
1491use warnings 'ambiguous' ;
1492sub f렏 {}
1493$a = ${f렏} ;
1494no warnings 'ambiguous' ;
1495$a = ${f렏} ;
1496EXPECT
1497Ambiguous use of ${f렏} resolved to $f렏 at - line 6.
1498########
1499# toke.c
1500use utf8;
1501use open qw( :utf8 :std );
1502use warnings;
1503CORE::렏;
1504EXPECT
1505CORE::렏 is not a keyword at - line 5.
1506########
1507# toke.c
1508# [perl #16249]
1509print '';
1510eval this_method_is_fake ();
1511EXPECT
1512Undefined subroutine &main::this_method_is_fake called at - line 4.
1513########
1514# toke.c
1515# [perl #107002] Erroneous ambiguity warnings
1516sub { # do not actually call require
1517  require a::b . 1; # These used to produce erroneous
1518  require a::b + 1; # ambiguity warnings.
1519}
1520EXPECT
1521########
1522# toke.c
1523# [perl #113094], [perl #119101], since reverted so no warnings generated
1524use warnings;
1525print "aa" =~ m{^a\{1,2\}$}, "A\n";
1526print "aa" =~ m{^a\x\{61\}$}, "B\n";
1527print "a\\x{6F}" =~ m{^a\\x\{6F\}$}, "C\n";
1528print "a\\o" =~ m{^a\\\x\{6F\}$}, "D\n";
1529print "a\\\\x{6F}" =~ m{^a\\\\x\{6F\}$}, "E\n";
1530print "a\\\\o"     =~ m{^a\\\\\x\{6F\}$}, "F\n";
1531print "aa" =~ m{^a{1,2}$}, "G\n";
1532print "aq" =~ m[^a\[a-z\]$], "H\n";
1533print "aq" =~ m(^a\(q\)$), "I\n";
1534EXPECT
1535Non-hex character '\\' terminates \x early.  Resolved as "\x00\\" in regex; marked by <-- HERE in m/^a\x <-- HERE \{61\}$/ at - line 5.
1536Non-hex character '\\' terminates \x early.  Resolved as "\x00\\" in regex; marked by <-- HERE in m/^a\\\x <-- HERE \{6F\}$/ at - line 7.
1537Non-hex character '\\' terminates \x early.  Resolved as "\x00\\" in regex; marked by <-- HERE in m/^a\\\\\x <-- HERE \{6F\}$/ at - line 9.
1538A
1539B
15401C
1541D
15421E
1543F
15441G
1545H
1546I
1547########
1548# toke.c
1549#[perl #119123] disallow literal control character variables
1550*{
1551    Foo
1552}; # shouldn't warn on {\n, even though \n is a control character
1553EXPECT
1554########
1555# toke.c
1556# [perl #120288] -X at start of line gave spurious warning, where X is not
1557# a filetest operator
1558-a;
1559;-a;
1560EXPECT
1561########
1562# toke.c
1563# [perl #124113] Compile-time warning with UTF8 variable in array index
1564use warnings;
1565use utf8;
1566my $�� = 0;
1567my @array = (0);
1568my $v = $array[ 0 + $�� ];
1569   $v = $array[ $�� + 0 ];
1570EXPECT
1571########
1572# toke.c
1573# Allow Unicode here doc boundaries
1574use warnings;
1575use utf8;
1576my $v = <<EnFraçais;
1577Comme ca!
1578EnFraçais
1579print $v;
1580EXPECT
1581Comme ca!
1582########
1583# toke.c
1584# Fix 'Use of "..." without parentheses is ambiguous' warning for
1585# Unicode function names.  If not under PERL_UNICODE, this will generate
1586# a "Wide character" warning
1587use utf8;
1588use warnings;
1589sub ��(;$) { return 0; }
1590my $v = �� - 5;
1591EXPECT
1592OPTION regex
1593(Wide character.*\n)?Warning: Use of "��" without parentheses is ambiguous
1594########
1595# RT #4346 Case 1: Warnings for print (...)
1596# TODO RT #4346: Warnings for print(...) are inconsistent
1597use warnings;
1598print ("((\n");
1599print (">>\n");
1600EXPECT
1601print (...) interpreted as function at - line 3.
1602print (...) interpreted as function at - line 4.
1603((
1604>>
1605########
1606# RT #4346 Case 2: Warnings for print (...)
1607use warnings;
1608print ("((\n");
1609print (">>\n")
1610EXPECT
1611print (...) interpreted as function at - line 3.
1612print (...) interpreted as function at - line 4.
1613((
1614>>
1615########
1616# RT #4346 Case 3: Warnings for print (...)
1617# TODO RT #4346: Warnings for print(...) are inconsistent
1618use warnings;
1619print (">>\n");
1620print ("((\n");
1621EXPECT
1622print (...) interpreted as function at - line 3.
1623print (...) interpreted as function at - line 4.
1624>>
1625((
1626########
1627# RT #4346 Case 4: Warnings for print (...)
1628# TODO RT #4346: Warnings for print(...) are inconsistent
1629use warnings;
1630print (")\n");
1631print ("))\n");
1632EXPECT
1633print (...) interpreted as function at - line 3.
1634print (...) interpreted as function at - line 4.
1635)
1636))
1637########
1638# NAME  Non-grapheme delimiters
1639BEGIN{
1640    if (ord('A') == 193) {
1641        print "SKIPPED\n# ebcdic platforms generates different Malformed UTF-8 warnings.";
1642        exit 0;
1643    }
1644}
1645use utf8;
1646my $a = qr ̂foobar̂;
1647EXPECT
1648Use of unassigned code point or non-standalone grapheme for a delimiter is not allowed at - line 8, near "= "
1649Execution of - aborted due to compilation errors.
1650########
1651# NAME  [perl #130567] Assertion failure
1652BEGIN {
1653    if (ord('A') != 65) {
1654        print "SKIPPED\n# test is ASCII-specific";
1655        exit 0;
1656    }
1657}
1658no warnings "uninitialized";
1659$_= "";
1660s//\3000/;
1661s//"\x{180};;s\221(*$@$`\241\275";/gee;
1662s//"s\221\302\302\302\302\302\302\302$@\241\275";/gee;
1663EXPECT
1664########
1665# NAME  [perl #130666] Assertion failure
1666no warnings "uninitialized";
1667BEGIN{$^H=-1};my $l; s�$0[$l]��
1668EXPECT
1669########
1670# NAME  [perl #129036] Assertion failure
1671BEGIN{$0="";$^H=hex join""=>A00000}p?
1672EXPECT
1673OPTION fatal
1674syntax error at - line 1, at EOF
1675Execution of - aborted due to compilation errors.
1676########
1677# NAME  [perl #130655]
1678use utf8;
1679qw∘foo ∞ ♥ bar∘
1680EXPECT
1681########
1682# NAME  [perl #134064]
1683BEGIN {
1684    if (ord('A') == 193) {
1685        print "SKIPPED\n# test is ASCII-specific, but could be extended to EBCDIC";
1686        exit 0;
1687    }
1688}
1689use utf8;
1690$foo="m'\302'";
1691eval $foo ;
1692print "The eval did not crash the program\n"
1693EXPECT
1694OPTION regex
1695Malformed UTF-8 character: .*non-continuation.*
1696The eval did not crash the program
1697########
1698# NAME [perl #133850] print $fh $1 in s///e expression
1699use warnings;
1700my $fh = \*STDOUT;
1701$_ = "abc";
1702s/(x)/ print $fh $1 /e;
1703EXPECT
1704########
1705# NAME [perl #133850] side case
1706use warnings;
1707my $fh = \*STDOUT;
1708my $y = "";
1709my $x = "${print $fh $y; \'x'}";
1710EXPECT
1711########
1712# NAME [perl #133850] another case
1713use warnings;
1714my $time = 1;
1715$_ = "";
1716s/^/ ${time} /e
1717EXPECT
1718Ambiguous use of ${time} resolved to $time at - line 4.
1719########
1720# NAME [perl #133850] another case
1721use warnings;
1722%x = qw(a b c d);
1723$_ = "";
1724s/^/ @x {a} /e
1725EXPECT
1726Scalar value @x{"a"} better written as $x{"a"} at - line 4.
1727########
1728# NAME Warn on 32-bit code points
1729# SKIP ? $Config{uvsize} < 8
1730use warnings 'portable';
1731my $a = "\x{8000_0000}";
1732my $b = "\o{20_000_000_000}";
1733EXPECT
1734Code point 0x80000000 is not Unicode, requires a Perl extension, and so is not portable at - line 2.
1735Code point 0x80000000 is not Unicode, requires a Perl extension, and so is not portable at - line 3.
1736########
1737# NAME Check that our Multidimensional array heuristic doesn't false positive on function calls
1738use warnings;
1739my $str= "rst";
1740my $substr= "s";
1741my @array="A".."C";
1742# force a numeric warning, but we should NOT see a Multidimensional warning here
1743my $trigger_num_warn= $array[index $str,$substr] + 1;
1744# this should trigger a Multidimensional warning
1745my $should_warn_multi= $array[0x1,0x2];
1746EXPECT
1747Multidimensional syntax $array[0x1,0x2] not supported at - line 8.
1748Argument "B" isn't numeric in addition (+) at - line 6.
1749########
1750# NAME extra paired delimiters Latin1 range in UTF-8
1751BEGIN { binmode STDERR, ":utf8" }
1752use utf8;
1753use feature 'extra_paired_delimiters';
1754no warnings 'experimental::extra_paired_delimiters';
1755my $good = q<this string uses ASCII delimiter; no warning>;
1756my $good2 = q«this string has mirrored delimiters in either order»;
1757my $good3 = q»and reversed«;
1758no feature 'extra_paired_delimiters';
1759my $warn3 = q«this string starts and ends with the lhs terminator«;
1760my $warn4 = q»this string starts and ends with the rhs mirror»;
1761EXPECT
1762Use of '«' is deprecated as a string delimiter at - line 9.
1763Use of '»' is deprecated as a string delimiter at - line 10.
1764########
1765# NAME extra paired delimiters above Latin1 range
1766BEGIN { binmode STDERR, ":utf8" }
1767use utf8;
1768use feature 'extra_paired_delimiters';
1769no warnings 'experimental::extra_paired_delimiters';
1770my $good = q<this string uses ASCII delimiter; no warning>;
1771my $good2 = q《this string has a mirrored terminator》;
1772my $warn2 = q》this string starts and ends with the rhs mirror》;
1773my $good3 = q‹this string has mirrored delimiters in either order›;
1774my $good3 = q›and reversed‹;
1775no feature 'extra_paired_delimiters';
1776my $warn3 = q《this string starts and ends with the lhs terminator《;
1777my $warn4 = q》this string starts and ends with the rhs mirror》;
1778my $warn5 = q‹this string starts and ends with the lhs terminator‹;
1779my $warn6 = q›this string starts and ends with the rhs mirror›;
1780EXPECT
1781Use of '》' is deprecated as a string delimiter at - line 7.
1782Use of '《' is deprecated as a string delimiter at - line 11.
1783Use of '》' is deprecated as a string delimiter at - line 12.
1784Use of '‹' is deprecated as a string delimiter at - line 13.
1785Use of '›' is deprecated as a string delimiter at - line 14.
1786########
1787