xref: /openbsd/gnu/usr.bin/perl/t/lib/croak/toke (revision 097a140d)
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;
103104EXPECT
105Can't find string terminator "«" anywhere before EOF at - line 3.
106########
107# NAME Unterminated q// with non-Latin-1 delimiter
108BEGIN { binmode STDERR, ":utf8" }
109use utf8;
110q 옷
111EXPECT
112Can't find string terminator "옷" anywhere before EOF at - line 3.
113########
114# NAME /\N{/
115/\N{/
116EXPECT
117Missing right brace on \N{} or unescaped left brace after \N at - line 1, within pattern
118Execution of - aborted due to compilation errors.
119########
120# NAME map{for our *a...
121map{for our *a (1..10) {$_.=$x}}
122EXPECT
123Missing $ on loop variable at - line 1.
124########
125# NAME Missing name in "my sub"
126use feature 'lexical_subs'; my sub;
127EXPECT
128Missing name in "my sub" at - line 1.
129########
130# NAME Missing name in "our sub"
131use feature 'lexical_subs'; our sub;
132EXPECT
133Missing name in "our sub" at - line 1.
134########
135# NAME Missing name in "state sub"
136use 5.01;
137state sub;
138EXPECT
139Missing name in "state sub" at - line 2.
140########
141# NAME our sub pack::foo
142our sub foo::bar;
143EXPECT
144No package name allowed for subroutine &foo::bar in "our" at - line 1, near "our sub foo::bar"
145Execution of - aborted due to compilation errors.
146########
147# NAME my sub pack::foo
148use feature 'lexical_subs', 'state';
149my sub foo::bar;
150state sub foo::bear;
151EXPECT
152"my" subroutine &foo::bar can't be in a package at - line 2, near "my sub foo::bar"
153"state" subroutine &foo::bear can't be in a package at - line 3, near "state sub foo::bear"
154Execution of - aborted due to compilation errors.
155########
156# NAME Integer constant overloading returning undef
157use overload;
158BEGIN { overload::constant integer => sub {}; undef *^H }
1591
160EXPECT
161Constant(1) unknown at - line 3, at end of line
162Execution of - aborted due to compilation errors.
163########
164# NAME Float constant overloading returning undef
165use overload;
166BEGIN { overload::constant float => sub {}; undef *^H }
1671.1
168EXPECT
169Constant(1.1) unknown at - line 3, at end of line
170Execution of - aborted due to compilation errors.
171########
172# NAME Binary constant overloading returning undef
173use overload;
174BEGIN { overload::constant binary => sub {}; undef *^H }
1750x1
176EXPECT
177Constant(0x1) unknown at - line 3, at end of line
178Execution of - aborted due to compilation errors.
179########
180# NAME String constant overloading returning undef
181use overload;
182BEGIN { overload::constant q => sub {}; undef *^H }
183'1', "1$_", tr"a"", s""a"
184EXPECT
185Constant(q) unknown at - line 3, near "'1'"
186Constant(qq) unknown at - line 3, within string
187Constant(tr) unknown at - line 3, within string
188Constant(s) unknown at - line 3, within string
189Execution of - aborted due to compilation errors.
190########
191# NAME Regexp constant overloading when *^H is undefined
192use overload;
193BEGIN { overload::constant qr => sub {}; undef *^H }
194/a/
195EXPECT
196Constant(qq) unknown at - line 3, within pattern
197Execution of - aborted due to compilation errors.
198########
199# NAME Regexp constant overloading when *^H is undefined
200use overload;
201BEGIN { overload::constant qr => sub {}; undef *^H }
202m'a'
203EXPECT
204Constant(q) unknown at - line 3, within pattern
205Execution of - aborted due to compilation errors.
206########
207# NAME \N{...} when charnames fails to load but without an error
208# SKIP ? exists $ENV{PERL_UNICODE} ? "Unreliable under some PERL_UNICODE settings" : 0
209BEGIN { ++$_ for @INC{"charnames.pm","_charnames.pm"} }
210"\N{a}"
211EXPECT
212Constant(\N{a}) unknown at - line 2, within string
213Execution of - aborted due to compilation errors.
214########
215# NAME Integer constant overloading returning undef
216use overload;
217BEGIN { overload::constant integer => sub {} }
2181
219EXPECT
220Constant(1): Call to &{$^H{integer}} did not return a defined value at - line 3, at end of line
221Execution of - aborted due to compilation errors.
222########
223# NAME Float constant overloading returning undef
224use overload;
225BEGIN { overload::constant float => sub {} }
2261.1
227EXPECT
228Constant(1.1): Call to &{$^H{float}} did not return a defined value at - line 3, at end of line
229Execution of - aborted due to compilation errors.
230########
231# NAME Binary constant overloading returning undef
232use overload;
233BEGIN { overload::constant binary => sub {} }
2340x1
235EXPECT
236Constant(0x1): Call to &{$^H{binary}} did not return a defined value at - line 3, at end of line
237Execution of - aborted due to compilation errors.
238########
239# NAME String constant overloading returning undef
240use overload;
241BEGIN { overload::constant q => sub {} }
242'1', "1$_", tr"a"", s""a"
243EXPECT
244Constant(q): Call to &{$^H{q}} did not return a defined value at - line 3, near "'1'"
245Constant(qq): Call to &{$^H{q}} did not return a defined value at - line 3, within string
246Constant(tr): Call to &{$^H{q}} did not return a defined value at - line 3, within string
247Constant(s): Call to &{$^H{q}} did not return a defined value at - line 3, within string
248Execution of - aborted due to compilation errors.
249########
250# NAME Regexp constant overloading returning undef
251use overload;
252BEGIN { overload::constant qr => sub {} }
253/a/
254EXPECT
255Constant(qq): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
256Execution of - aborted due to compilation errors.
257########
258# NAME Regexp constant overloading returning undef
259use overload;
260BEGIN { overload::constant qr => sub {} }
261m'a'
262EXPECT
263Constant(q): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
264Execution of - aborted due to compilation errors.
265########
266# NAME Failed constant overloading should not cause a double free
267use overload;
268BEGIN { overload::constant q => sub {}; undef *^H }
269undef(1,2);
270undef(1,2);
271undef(1,2);
272undef(1,2);
273undef(1,2);
274undef(1,2);
275undef(1,2);
276undef(1,2);
277undef(1,2);
278"a"
279EXPECT
280Too many arguments for undef operator at - line 3, near "2)"
281Too many arguments for undef operator at - line 4, near "2)"
282Too many arguments for undef operator at - line 5, near "2)"
283Too many arguments for undef operator at - line 6, near "2)"
284Too many arguments for undef operator at - line 7, near "2)"
285Too many arguments for undef operator at - line 8, near "2)"
286Too many arguments for undef operator at - line 9, near "2)"
287Too many arguments for undef operator at - line 10, near "2)"
288Too many arguments for undef operator at - line 11, near "2)"
289Constant(q) unknown at - line 12, near ""a""
290- has too many errors.
291########
292# NAME Bad name after ' (with other helpful messages)
293sub has{}
294has erdef => (
295    isa => 'Int',
296    is => 'ro,
297    default => sub { 1 }
298);
299
300has cxxc => (
301    isa => 'Int',
302    is => 'ro',
303    default => sub { 1 }
304);
305EXPECT
306Bareword found where operator expected at - line 9, near "isa => 'Int"
307  (Might be a runaway multi-line '' string starting on line 4)
308	(Do you need to predeclare isa?)
309Bad name after Int' at - line 9.
310########
311# NAME Bad name after :: (with other helpful messages)
312sub has{}
313has erdef => (
314    isa => 'Int',
315    is => "ro,
316    default => sub { 1 }
317);
318
319has cxxc => (
320    isa => "Foo::$subpackage",
321    is => 'ro',
322    default => sub { 1 }
323);
324EXPECT
325Bareword found where operator expected at - line 9, near "isa => "Foo"
326  (Might be a runaway multi-line "" string starting on line 4)
327	(Do you need to predeclare isa?)
328Bad name after Foo:: at - line 9.
329########
330# NAME Unterminated delimiter for here document
331<<"foo
332EXPECT
333Unterminated delimiter for here document at - line 1.
334########
335# NAME my (our $x) errors
336my (our $x);
337EXPECT
338Can't redeclare "our" in "my" at - line 1, near "(our"
339Execution of - aborted due to compilation errors.
340########
341# NAME our (my $x) errors
342our (my $x);
343EXPECT
344Can't redeclare "my" in "our" at - line 1, near "(my"
345Execution of - aborted due to compilation errors.
346########
347# NAME state (my $x) errors
348use feature 'state';
349state (my $x);
350EXPECT
351Can't redeclare "my" in "state" at - line 2, near "(my"
352Execution of - aborted due to compilation errors.
353########
354# NAME our (state $x) errors
355use feature 'state';
356our (state $x);
357EXPECT
358Can't redeclare "state" in "our" at - line 2, near "(state"
359Execution of - aborted due to compilation errors.
360########
361# NAME my (my $x) errors
362my (my $x, $y, $z);
363EXPECT
364Can't redeclare "my" in "my" at - line 1, near "(my"
365Execution of - aborted due to compilation errors.
366########
367# NAME our (our $x) errors
368our ($x, our($y), $z);
369EXPECT
370Can't redeclare "our" in "our" at - line 1, near ", our"
371Execution of - aborted due to compilation errors.
372########
373# NAME state (state $x) errors
374use feature 'state';
375state ($x, $y, state $z);
376EXPECT
377Can't redeclare "state" in "state" at - line 2, near ", state"
378Execution of - aborted due to compilation errors.
379########
380# NAME BEGIN <> [perl #125341]
381BEGIN <>
382EXPECT
383Illegal declaration of subroutine BEGIN at - line 1.
384########
385# NAME multiple conflict markers
386<<<<<<< yours:sample.txt
387my $some_code;
388=======
389my $some_other_code;
390>>>>>>> theirs:sample.txt
391EXPECT
392Version control conflict marker at - line 1, near "<<<<<<<"
393Version control conflict marker at - line 3, near "======="
394Version control conflict marker at - line 5, near ">>>>>>>"
395Execution of - aborted due to compilation errors.
396########
397# NAME (Might be a runaway multi-line...) with Latin-1 delimiters in utf8
398BEGIN { binmode STDERR, ':utf8' }
399use utf8;
400401« time
402EXPECT
403syntax error at - line 4, near "« time"
404  (Might be a runaway multi-line «« string starting on line 3)
405Execution of - aborted due to compilation errors.
406########
407# NAME (Might be a runaway multi-line...) with non-Latin-1 delimiters
408BEGIN { binmode STDERR, ':utf8' }
409use utf8;
410q ϡ
411ϡ time
412EXPECT
413syntax error at - line 4, near "ϡ time"
414  (Might be a runaway multi-line ϡϡ string starting on line 3)
415Execution of - aborted due to compilation errors.
416########
417# NAME tr/// handling of mis-formatted \o characters
418# may only fail with ASAN
419tr/\o-0//;
420EXPECT
421Missing braces on \o{} at - line 2, within string
422Execution of - aborted due to compilation errors.
423########
424# NAME bare <<
425$a = <<;
426
427EXPECT
428Use of bare << to mean <<"" is forbidden at - line 1.
429########
430# NAME bare <<~
431$a = <<~;
432EXPECT
433Use of bare << to mean <<"" is forbidden at - line 1.
434########
435# NAME bare <<~
436$a = <<~ ;
437
438EXPECT
439Use of bare << to mean <<"" is forbidden at - line 1.
440########
441# NAME incomplete floating point decimal exponent (#131725)
4421e--5
443EXPECT
444Bareword found where operator expected at - line 1, near "1e"
445	(Missing operator before e?)
446Number found where operator expected at - line 1, near "--5"
447	(Missing operator before 5?)
448syntax error at - line 1, near "1e"
449Execution of - aborted due to compilation errors.
450########
451# NAME signature with non-"=" assignop #131777
452use feature 'signatures';
453no warnings 'experimental::signatures';
454sub foo ($a += 1)
455EXPECT
456Illegal operator following parameter in a subroutine signature at - line 3, near "($a += 1"
457syntax error at - line 3, near "($a += 1"
458Execution of - aborted due to compilation errors.
459########
460# NAME tr/// range with empty \N{} at the start
461tr//\N{}-0/;
462EXPECT
463Unknown charname '' at - line 1, within string
464Execution of - aborted due to compilation errors.
465########
466# NAME octal fp with non-octal digits after the decimal point
46701.1234567p0;
46807.8p0;
469EXPECT
470Bareword found where operator expected at - line 2, near "8p0"
471	(Missing operator before p0?)
472syntax error at - line 2, near "8p0"
473Execution of - aborted due to compilation errors.
474########
475# NAME binary fp with non-binary digits after the decimal point
4760b1.10p0;
4770b1.2p0;
478EXPECT
479Bareword found where operator expected at - line 2, near "2p0"
480	(Missing operator before p0?)
481syntax error at - line 2, near "2p0"
482Execution of - aborted due to compilation errors.
483########
484# NAME dump() must be written as CORE::dump() as of Perl 5.30
485BEGIN { $^C = 1; }
486dump;
487CORE::dump;
488EXPECT
489dump() must be written as CORE::dump() as of Perl 5.30 at - line 2.
490########
491# NAME check Prototype not terminated includes line number (133524)
492sub t1 {}
493sub t2 (}
494EXPECT
495Prototype not terminated at - line 2.
496########
497# NAME [perl #132158] format with syntax errors
498format=
499@
500=h
501=cut
502EXPECT
503syntax error at - line 4, next token ???
504Execution of - aborted due to compilation errors.
505########
506# NAME [perl #134045] incomplete hex number
5070x x 2;
5080xx 2;
5090x_;
5100b;
511EXPECT
512No digits found for hexadecimal literal at - line 1, near "0x "
513No digits found for hexadecimal literal at - line 2, near "0xx"
514No digits found for hexadecimal literal at - line 3, near "0x_;"
515No digits found for binary literal at - line 4, near "0b;"
516Execution of - aborted due to compilation errors.
517########
518# NAME [perl #130585] close paren in subparse
519qr!@{s{0})(?{!;
520EXPECT
521syntax error at - line 1, near "})"
522Execution of - aborted due to compilation errors.
523########
524# NAME [perl #130585] close paren in subparse - a few more tests
525my ($x, %y, @z);
526qq!$x\U $z[0] $y{a}\E $z[1]!;
527qq!$x\U@{s{0})(?{!;
528EXPECT
529syntax error at - line 3, near ")("
530Execution of - aborted due to compilation errors.
531########
532# NAME [perl #134310] don't confuse S_no_op() with PL_bufptr after s
5330 0x@
534EXPECT
535Number found where operator expected at - line 1, near "0 0x"
536	(Missing operator before  0x?)
537Array found where operator expected at - line 1, near "0x@
538;"
539	(Missing operator before ;?)
540No digits found for hexadecimal literal at - line 1, near "0 0x@"
541syntax error at - line 1, near "0 0x"
542Execution of - aborted due to compilation errors.
543########
544# NAME Forbid illegal \x{} code points
545use Config;
546if ($Config{uvsize} < 8) {
547    my $a = "\x{8000_0000}";
548}
549else {
550    my $a = "\x{8000_0000_0000_0000}";
551}
552EXPECT
553OPTIONS regex
554Use of code point 0x80000000(00000000)? is not allowed; the permissible max is 0x7FFFFFFF(FFFFFFFF)? at - line \d+.
555########
556# NAME Forbid illegal \o{} code points
557use Config;
558if ($Config{uvsize} < 8) {
559    my $b = "\o{20_000_000_000}";
560}
561else {
562    my $b = "\o{1_000_000_000_000_000_000_000}";
563}
564EXPECT
565OPTIONS regex
566Use of code point 0x80000000(00000000)? is not allowed; the permissible max is 0x7FFFFFFF(FFFFFFFF)? at - line \d+.
567########
568# NAME gh-17645: conflict marker detection should not read out of bounds
569m/$0[
570==0/
571EXPECT
572syntax error at - line 2, near "[
573=="
574  (Might be a runaway multi-line // string starting on line 1)
575Execution of - aborted due to compilation errors.
576