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