xref: /openbsd/gnu/usr.bin/perl/t/lib/croak/toke (revision 3bef86f7)
1__END__
2# NAME foo found where operator expected
3myfunc 1,2,3
4EXPECT
5Number found where operator expected at - line 1, near "myfunc 1"
6	(Do you need to predeclare myfunc?)
7syntax error at - line 1, near "myfunc 1"
8Execution of - aborted due to compilation errors.
9########
10# NAME foo found where operator expected (after strict error, w/fatal warnings)
11use warnings FATAL => 'all';
12use strict;
13$foo;
14myfunc 1,2,3
15EXPECT
16Global symbol "$foo" requires explicit package name (did you forget to declare "my $foo"?) at - line 3.
17Number found where operator expected at - line 4, near "myfunc 1"
18	(Do you need to predeclare myfunc?)
19syntax error at - line 4, near "myfunc 1"
20Execution of - aborted due to compilation errors.
21########
22# NAME (Missing operator before ${?) [perl #123737]
230${
24EXPECT
25Scalar found where operator expected at - line 1, near "0${"
26	(Missing operator before ${?)
27syntax error at - line 1, near "0$"
28Missing right curly or square bracket at - line 1, at end of line
29Execution of - aborted due to compilation errors.
30########
31# NAME (Missing operator before $#{?) [perl #123737]
320$#{
33EXPECT
34Array length found where operator expected at - line 1, near "0$#{"
35	(Missing operator before $#{?)
36syntax error at - line 1, near "0$#"
37Missing right curly or square bracket at - line 1, at end of line
38Execution of - aborted due to compilation errors.
39########
40# NAME (Missing operator before @foo) [perl #123737]
410@foo
42EXPECT
43Array found where operator expected at - line 1, near "0@foo"
44	(Missing operator before @foo?)
45syntax error at - line 1, near "0@foo
46"
47Execution of - aborted due to compilation errors.
48########
49# NAME (Missing operator before @{) [perl #123737]
500@{
51EXPECT
52Array found where operator expected at - line 1, near "0@{"
53	(Missing operator before @{?)
54syntax error at - line 1, near "0@"
55Missing right curly or square bracket at - line 1, at end of line
56Execution of - aborted due to compilation errors.
57########
58# NAME Unterminated here-doc in string eval
59eval "<<foo"; die $@
60EXPECT
61Can't find string terminator "foo" anywhere before EOF at (eval 1) line 1.
62########
63# NAME Unterminated here-doc in s/// string eval
64eval "s//<<foo/e"; die $@
65EXPECT
66Can't find string terminator "foo" anywhere before EOF at (eval 1) line 1.
67########
68# NAME Unterminated here-doc in string
69"${<<foo"; # Used to give ‘Attempt to free blah blah blah’
70EXPECT
71Can't find string terminator "foo" anywhere before EOF at - line 1.
72########
73# NAME Unterminated here-doc with non-Latin-1 terminator
74BEGIN { binmode STDERR, ":utf8" }
75use utf8;
76<<옷옷
77EXPECT
78Can't find string terminator "옷옷" anywhere before EOF at - line 3.
79########
80# NAME Unterminated qw//
81qw/
82EXPECT
83Can't find string terminator "/" anywhere before EOF at - line 1.
84########
85# NAME Unterminated q//
86qw/
87EXPECT
88Can't find string terminator "/" anywhere before EOF at - line 1.
89########
90# NAME Unterminated ''
91'
92EXPECT
93Can't find string terminator "'" anywhere before EOF at - line 1.
94########
95# NAME Unterminated ""
96"
97EXPECT
98Can't find string terminator '"' anywhere before EOF at - line 1.
99########
100# NAME Unterminated q// with non-ASCII delimiter, under utf8
101BEGIN { binmode STDERR, ":utf8" }
102use utf8;
103no warnings 'deprecated';
104105EXPECT
106Can't find string terminator "«" anywhere before EOF at - line 4.
107########
108# NAME Unterminated q// with non-Latin-1 delimiter
109BEGIN { binmode STDERR, ":utf8" }
110use utf8;
111q 옷
112EXPECT
113Can't find string terminator "옷" anywhere before EOF at - line 3.
114########
115# NAME extra paired delimiters Latin1 range in UTF-8
116BEGIN { binmode STDERR, ":utf8" }
117use utf8;
118use feature 'extra_paired_delimiters';
119no warnings 'experimental::extra_paired_delimiters';
120my $good = q«this string has a mirrored terminator»;
121my $bad = q«this string needs to have a mirrored terminator«;
122EXPECT
123Can't find string terminator "»" anywhere before EOF at - line 6.
124########
125# NAME reversed extra paired delimiters Latin1 range in UTF-8
126BEGIN { binmode STDERR, ":utf8" }
127use utf8;
128use feature 'extra_paired_delimiters';
129no warnings 'experimental::extra_paired_delimiters';
130my $good = q»this string has a mirrored terminator«;
131my $bad = q»this string needs to have a mirrored terminator»;
132EXPECT
133Can't find string terminator "«" anywhere before EOF at - line 6.
134########
135# NAME paired non-ASCII Latin1 delimiters need feature enabled, in UTF-8
136BEGIN { binmode STDERR, ":utf8" }
137use utf8;
138my $good = q«this string works as before without the feature enabled«;
139no warnings 'deprecated';
140my $bad = q«this string has a mirrored terminator»;
141EXPECT
142Use of '«' is deprecated as a string delimiter at - line 3.
143Can't find string terminator "«" anywhere before EOF at - line 5.
144########
145# NAME paired above Latin1 delimiters need feature enabled
146BEGIN { binmode STDERR, ":utf8" }
147use utf8;
148my $bad = q《this string has a mirrored terminator》;
149EXPECT
150Use of '《' is deprecated as a string delimiter at - line 3.
151Can't find string terminator "《" anywhere before EOF at - line 3.
152########
153# NAME /\N{/
154/\N{/
155EXPECT
156Missing right brace on \N{} or unescaped left brace after \N at - line 1, within pattern
157Execution of - aborted due to compilation errors.
158########
159# NAME map{for our *a...
160map{for our *a (1..10) {$_.=$x}}
161EXPECT
162Missing $ on loop variable at - line 1.
163########
164# NAME Missing name in "my sub"
165use feature 'lexical_subs'; my sub;
166EXPECT
167Missing name in "my sub" at - line 1.
168########
169# NAME Missing name in "our sub"
170use feature 'lexical_subs'; our sub;
171EXPECT
172Missing name in "our sub" at - line 1.
173########
174# NAME Missing name in "state sub"
175use 5.01;
176state sub;
177EXPECT
178Missing name in "state sub" at - line 2.
179########
180# NAME our sub pack::foo
181our sub foo::bar;
182EXPECT
183No package name allowed for subroutine &foo::bar in "our" at - line 1, near "our sub foo::bar"
184Execution of - aborted due to compilation errors.
185########
186# NAME my sub pack::foo
187use feature 'lexical_subs', 'state';
188my sub foo::bar;
189state sub foo::bear;
190EXPECT
191"my" subroutine &foo::bar can't be in a package at - line 2, near "my sub foo::bar"
192"state" subroutine &foo::bear can't be in a package at - line 3, near "state sub foo::bear"
193Execution of - aborted due to compilation errors.
194########
195# NAME Integer constant overloading returning undef
196use overload;
197BEGIN { overload::constant integer => sub {}; undef *^H }
1981
199EXPECT
200Constant(1) unknown at - line 3, at end of line
201Execution of - aborted due to compilation errors.
202########
203# NAME Float constant overloading returning undef
204use overload;
205BEGIN { overload::constant float => sub {}; undef *^H }
2061.1
207EXPECT
208Constant(1.1) unknown at - line 3, at end of line
209Execution of - aborted due to compilation errors.
210########
211# NAME Binary constant overloading returning undef
212use overload;
213BEGIN { overload::constant binary => sub {}; undef *^H }
2140x1
215EXPECT
216Constant(0x1) unknown at - line 3, at end of line
217Execution of - aborted due to compilation errors.
218########
219# NAME String constant overloading returning undef
220use overload;
221BEGIN { overload::constant q => sub {}; undef *^H }
222'1', "1$_", tr"a"", s""a"
223EXPECT
224Constant(q) unknown at - line 3, near "'1'"
225Constant(qq) unknown at - line 3, within string
226Constant(tr) unknown at - line 3, within string
227Constant(s) unknown at - line 3, within string
228Execution of - aborted due to compilation errors.
229########
230# NAME Regexp constant overloading when *^H is undefined
231use overload;
232BEGIN { overload::constant qr => sub {}; undef *^H }
233/a/
234EXPECT
235Constant(qq) unknown at - line 3, within pattern
236Execution of - aborted due to compilation errors.
237########
238# NAME Regexp constant overloading when *^H is undefined
239use overload;
240BEGIN { overload::constant qr => sub {}; undef *^H }
241m'a'
242EXPECT
243Constant(q) unknown at - line 3, within pattern
244Execution of - aborted due to compilation errors.
245########
246# NAME \N{...} when charnames fails to load but without an error
247# SKIP ? exists $ENV{PERL_UNICODE} ? "Unreliable under some PERL_UNICODE settings" : 0
248BEGIN { ++$_ for @INC{"charnames.pm","_charnames.pm"} }
249"\N{a}"
250EXPECT
251Constant(\N{a}) unknown at - line 2, within string
252Execution of - aborted due to compilation errors.
253########
254# NAME Integer constant overloading returning undef
255use overload;
256BEGIN { overload::constant integer => sub {} }
2571
258EXPECT
259Constant(1): Call to &{$^H{integer}} did not return a defined value at - line 3, at end of line
260Execution of - aborted due to compilation errors.
261########
262# NAME Float constant overloading returning undef
263use overload;
264BEGIN { overload::constant float => sub {} }
2651.1
266EXPECT
267Constant(1.1): Call to &{$^H{float}} did not return a defined value at - line 3, at end of line
268Execution of - aborted due to compilation errors.
269########
270# NAME Binary constant overloading returning undef
271use overload;
272BEGIN { overload::constant binary => sub {} }
2730x1
274EXPECT
275Constant(0x1): Call to &{$^H{binary}} did not return a defined value at - line 3, at end of line
276Execution of - aborted due to compilation errors.
277########
278# NAME String constant overloading returning undef
279use overload;
280BEGIN { overload::constant q => sub {} }
281'1', "1$_", tr"a"", s""a"
282EXPECT
283Constant(q): Call to &{$^H{q}} did not return a defined value at - line 3, near "'1'"
284Constant(qq): Call to &{$^H{q}} did not return a defined value at - line 3, within string
285Constant(tr): Call to &{$^H{q}} did not return a defined value at - line 3, within string
286Constant(s): Call to &{$^H{q}} did not return a defined value at - line 3, within string
287Execution of - aborted due to compilation errors.
288########
289# NAME Regexp constant overloading returning undef
290use overload;
291BEGIN { overload::constant qr => sub {} }
292/a/
293EXPECT
294Constant(qq): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
295Execution of - aborted due to compilation errors.
296########
297# NAME Regexp constant overloading returning undef
298use overload;
299BEGIN { overload::constant qr => sub {} }
300m'a'
301EXPECT
302Constant(q): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
303Execution of - aborted due to compilation errors.
304########
305# NAME Failed constant overloading should not cause a double free
306use overload;
307BEGIN { overload::constant q => sub {}; undef *^H }
308undef(1,2);
309undef(1,2);
310undef(1,2);
311undef(1,2);
312undef(1,2);
313undef(1,2);
314undef(1,2);
315undef(1,2);
316undef(1,2);
317"a"
318EXPECT
319Too many arguments for undef operator at - line 3, near "2)"
320Too many arguments for undef operator at - line 4, near "2)"
321Too many arguments for undef operator at - line 5, near "2)"
322Too many arguments for undef operator at - line 6, near "2)"
323Too many arguments for undef operator at - line 7, near "2)"
324Too many arguments for undef operator at - line 8, near "2)"
325Too many arguments for undef operator at - line 9, near "2)"
326Too many arguments for undef operator at - line 10, near "2)"
327Too many arguments for undef operator at - line 11, near "2)"
328Constant(q) unknown at - line 12, near ""a""
329- has too many errors.
330########
331# NAME Bad name after ' (with other helpful messages)
332sub has{}
333has erdef => (
334    isa => 'Int',
335    is => 'ro,
336    default => sub { 1 }
337);
338
339has cxxc => (
340    isa => 'Int',
341    is => 'ro',
342    default => sub { 1 }
343);
344EXPECT
345Bareword found where operator expected at - line 9, near "isa => 'Int"
346  (Might be a runaway multi-line '' string starting on line 4)
347	(Do you need to predeclare isa?)
348Bad name after Int' at - line 9.
349########
350# NAME Bad name after :: (with other helpful messages)
351sub has{}
352has erdef => (
353    isa => 'Int',
354    is => "ro,
355    default => sub { 1 }
356);
357
358has cxxc => (
359    isa => "Foo::$subpackage",
360    is => 'ro',
361    default => sub { 1 }
362);
363EXPECT
364Bareword found where operator expected at - line 9, near "isa => "Foo"
365  (Might be a runaway multi-line "" string starting on line 4)
366	(Do you need to predeclare isa?)
367Bad name after Foo:: at - line 9.
368########
369# NAME Unterminated delimiter for here document
370<<"foo
371EXPECT
372Unterminated delimiter for here document at - line 1.
373########
374# NAME my (our $x) errors
375my (our $x);
376EXPECT
377Can't redeclare "our" in "my" at - line 1, near "(our"
378Execution of - aborted due to compilation errors.
379########
380# NAME our (my $x) errors
381our (my $x);
382EXPECT
383Can't redeclare "my" in "our" at - line 1, near "(my"
384Execution of - aborted due to compilation errors.
385########
386# NAME state (my $x) errors
387use feature 'state';
388state (my $x);
389EXPECT
390Can't redeclare "my" in "state" at - line 2, near "(my"
391Execution of - aborted due to compilation errors.
392########
393# NAME our (state $x) errors
394use feature 'state';
395our (state $x);
396EXPECT
397Can't redeclare "state" in "our" at - line 2, near "(state"
398Execution of - aborted due to compilation errors.
399########
400# NAME my (my $x) errors
401my (my $x, $y, $z);
402EXPECT
403Can't redeclare "my" in "my" at - line 1, near "(my"
404Execution of - aborted due to compilation errors.
405########
406# NAME our (our $x) errors
407our ($x, our($y), $z);
408EXPECT
409Can't redeclare "our" in "our" at - line 1, near ", our"
410Execution of - aborted due to compilation errors.
411########
412# NAME state (state $x) errors
413use feature 'state';
414state ($x, $y, state $z);
415EXPECT
416Can't redeclare "state" in "state" at - line 2, near ", state"
417Execution of - aborted due to compilation errors.
418########
419# NAME BEGIN <> [perl #125341]
420BEGIN <>
421EXPECT
422Illegal declaration of subroutine BEGIN at - line 1.
423########
424# NAME multiple conflict markers.
425# NOTE the <CONFLICT< style text is auto-replaced in test.pl run_multiple_progs
426<CONFLICT< yours:sample.txt
427my $some_code;
428=CONFLICT=
429my $some_other_code;
430>CONFLICT> theirs:sample.txt
431EXPECT
432Version control conflict marker at - line 1, near "<CONFLICT<"
433Version control conflict marker at - line 3, near "=CONFLICT="
434Version control conflict marker at - line 5, near ">CONFLICT>"
435Execution of - aborted due to compilation errors.
436########
437# NAME (Might be a runaway multi-line...) with Latin-1 delimiters in utf8
438BEGIN { binmode STDERR, ':utf8' }
439use utf8;
440no warnings 'deprecated';
441442« time
443EXPECT
444syntax error at - line 5, near "« time"
445  (Might be a runaway multi-line «« string starting on line 4)
446Execution of - aborted due to compilation errors.
447########
448# NAME (Might be a runaway multi-line...) with non-Latin-1 delimiters
449BEGIN { binmode STDERR, ':utf8' }
450use utf8;
451q ϡ
452ϡ time
453EXPECT
454syntax error at - line 4, near "ϡ time"
455  (Might be a runaway multi-line ϡϡ string starting on line 3)
456Execution of - aborted due to compilation errors.
457########
458# NAME tr/// handling of mis-formatted \o characters
459# may only fail with ASAN
460tr/\o-0//;
461EXPECT
462Missing braces on \o{} at - line 2, within string
463Execution of - aborted due to compilation errors.
464########
465# NAME bare <<
466$a = <<;
467
468EXPECT
469Use of bare << to mean <<"" is forbidden at - line 1.
470########
471# NAME bare <<~
472$a = <<~;
473EXPECT
474Use of bare << to mean <<"" is forbidden at - line 1.
475########
476# NAME bare <<~
477$a = <<~ ;
478
479EXPECT
480Use of bare << to mean <<"" is forbidden at - line 1.
481########
482# NAME incomplete floating point decimal exponent (#131725)
4831e--5
484EXPECT
485Bareword found where operator expected at - line 1, near "1e"
486	(Missing operator before e?)
487Number found where operator expected at - line 1, near "--5"
488	(Missing operator before 5?)
489syntax error at - line 1, near "1e"
490Execution of - aborted due to compilation errors.
491########
492# NAME signature with non-"=" assignop #131777
493use feature 'signatures';
494sub foo ($a += 1)
495EXPECT
496Illegal operator following parameter in a subroutine signature at - line 2, near "($a += 1"
497syntax error at - line 2, near "($a += 1"
498Execution of - aborted due to compilation errors.
499########
500# NAME tr/// range with empty \N{} at the start
501tr//\N{}-0/;
502EXPECT
503Unknown charname '' at - line 1, within string
504Execution of - aborted due to compilation errors.
505########
506# NAME octal fp with non-octal digits after the decimal point
50701.1234567p0;
50807.8p0;
509EXPECT
510Bareword found where operator expected at - line 2, near "8p0"
511	(Missing operator before p0?)
512syntax error at - line 2, near "8p0"
513Execution of - aborted due to compilation errors.
514########
515# NAME binary fp with non-binary digits after the decimal point
5160b1.10p0;
5170b1.2p0;
518EXPECT
519Bareword found where operator expected at - line 2, near "2p0"
520	(Missing operator before p0?)
521syntax error at - line 2, near "2p0"
522Execution of - aborted due to compilation errors.
523########
524# NAME dump() must be written as CORE::dump() as of Perl 5.30
525BEGIN { $^C = 1; }
526dump;
527CORE::dump;
528EXPECT
529dump() must be written as CORE::dump() as of Perl 5.30 at - line 2.
530########
531# NAME check Prototype not terminated includes line number (133524)
532sub t1 {}
533sub t2 (}
534EXPECT
535Prototype not terminated at - line 2.
536########
537# NAME [perl #132158] format with syntax errors
538format=
539@
540=h
541=cut
542EXPECT
543syntax error at - line 4, next token ???
544Execution of - aborted due to compilation errors.
545########
546# NAME [perl #134125] [gh #17010] incomplete hex number
5470x x 2;
5480xx 2;
5490x_;
5500b;
551EXPECT
552No digits found for hexadecimal literal at - line 1, near "0x "
553No digits found for hexadecimal literal at - line 2, near "0xx"
554No digits found for hexadecimal literal at - line 3, near "0x_;"
555No digits found for binary literal at - line 4, near "0b;"
556Execution of - aborted due to compilation errors.
557########
558# NAME [perl #130585] close paren in subparse
559qr!@{s{0})(?{!;
560EXPECT
561syntax error at - line 1, near "})"
562Execution of - aborted due to compilation errors.
563########
564# NAME [perl #130585] close paren in subparse - a few more tests
565my ($x, %y, @z);
566qq!$x\U $z[0] $y{a}\E $z[1]!;
567qq!$x\U@{s{0})(?{!;
568EXPECT
569syntax error at - line 3, near ")("
570Execution of - aborted due to compilation errors.
571########
572# NAME [perl #134310] don't confuse S_no_op() with PL_bufptr after s
5730 0x@
574EXPECT
575Number found where operator expected at - line 1, near "0 0x"
576	(Missing operator before  0x?)
577Array found where operator expected at - line 1, near "0x@
578;"
579	(Missing operator before ;?)
580No digits found for hexadecimal literal at - line 1, near "0 0x@"
581syntax error at - line 1, near "0 0x"
582Execution of - aborted due to compilation errors.
583########
584# NAME Forbid illegal \x{} code points
585use Config;
586if ($Config{uvsize} < 8) {
587    my $a = "\x{8000_0000}";
588}
589else {
590    my $a = "\x{8000_0000_0000_0000}";
591}
592EXPECT
593OPTIONS regex
594Use of code point 0x80000000(00000000)? is not allowed; the permissible max is 0x7FFFFFFF(FFFFFFFF)? at - line \d+.
595########
596# NAME Forbid illegal \o{} code points
597use Config;
598if ($Config{uvsize} < 8) {
599    my $b = "\o{20_000_000_000}";
600}
601else {
602    my $b = "\o{1_000_000_000_000_000_000_000}";
603}
604EXPECT
605OPTIONS regex
606Use of code point 0x80000000(00000000)? is not allowed; the permissible max is 0x7FFFFFFF(FFFFFFFF)? at - line \d+.
607########
608# NAME gh-17645: conflict marker detection should not read out of bounds
609m/$0[
610==0/
611EXPECT
612syntax error at - line 2, near "[
613=="
614  (Might be a runaway multi-line // string starting on line 1)
615Execution of - aborted due to compilation errors.
616