This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
e7bf609637cd29a82918544b391883611a2a33e9
[perl5.git] / t / lib / croak / toke
1 __END__
2 # NAME foo found where operator expected
3 myfunc 1,2,3
4 EXPECT
5 Number found where operator expected at - line 1, near "myfunc 1"
6         (Do you need to predeclare myfunc?)
7 syntax error at - line 1, near "myfunc 1"
8 Execution of - aborted due to compilation errors.
9 ########
10 # NAME foo found where operator expected (after strict error, w/fatal warnings)
11 use warnings FATAL => 'all';
12 use strict;
13 $foo;
14 myfunc 1,2,3
15 EXPECT
16 Global symbol "$foo" requires explicit package name (did you forget to declare "my $foo"?) at - line 3.
17 Number found where operator expected at - line 4, near "myfunc 1"
18         (Do you need to predeclare myfunc?)
19 syntax error at - line 4, near "myfunc 1"
20 Execution of - aborted due to compilation errors.
21 ########
22 # NAME (Missing operator before ${?) [perl #123737]
23 0${
24 EXPECT
25 Scalar found where operator expected at - line 1, near "0${"
26         (Missing operator before ${?)
27 syntax error at - line 1, near "0$"
28 Missing right curly or square bracket at - line 1, at end of line
29 Execution of - aborted due to compilation errors.
30 ########
31 # NAME (Missing operator before $#{?) [perl #123737]
32 0$#{
33 EXPECT
34 Array length found where operator expected at - line 1, near "0$#{"
35         (Missing operator before $#{?)
36 syntax error at - line 1, near "0$#"
37 Missing right curly or square bracket at - line 1, at end of line
38 Execution of - aborted due to compilation errors.
39 ########
40 # NAME (Missing operator before @foo) [perl #123737]
41 0@foo
42 EXPECT
43 Array found where operator expected at - line 1, near "0@foo"
44         (Missing operator before @foo?)
45 syntax error at - line 1, near "0@foo
46 "
47 Execution of - aborted due to compilation errors.
48 ########
49 # NAME (Missing operator before @{) [perl #123737]
50 0@{
51 EXPECT
52 Array found where operator expected at - line 1, near "0@{"
53         (Missing operator before @{?)
54 syntax error at - line 1, near "0@"
55 Missing right curly or square bracket at - line 1, at end of line
56 Execution of - aborted due to compilation errors.
57 ########
58 # NAME Unterminated here-doc in string eval
59 eval "<<foo"; die $@
60 EXPECT
61 Can't find string terminator "foo" anywhere before EOF at (eval 1) line 1.
62 ########
63 # NAME Unterminated here-doc in s/// string eval
64 eval "s//<<foo/e"; die $@
65 EXPECT
66 Can'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’
70 EXPECT
71 Can't find string terminator "foo" anywhere before EOF at - line 1.
72 ########
73 # NAME Unterminated here-doc with non-Latin-1 terminator
74 BEGIN { binmode STDERR, ":utf8" }
75 use utf8;
76 <<옷옷
77 EXPECT
78 Can't find string terminator "옷옷" anywhere before EOF at - line 3.
79 ########
80 # NAME Unterminated qw//
81 qw/
82 EXPECT
83 Can't find string terminator "/" anywhere before EOF at - line 1.
84 ########
85 # NAME Unterminated q//
86 qw/
87 EXPECT
88 Can't find string terminator "/" anywhere before EOF at - line 1.
89 ########
90 # NAME Unterminated ''
91 '
92 EXPECT
93 Can't find string terminator "'" anywhere before EOF at - line 1.
94 ########
95 # NAME Unterminated ""
96 "
97 EXPECT
98 Can't find string terminator '"' anywhere before EOF at - line 1.
99 ########
100 # NAME Unterminated q// with non-ASCII delimiter, under utf8
101 BEGIN { binmode STDERR, ":utf8" }
102 use utf8;
103
104 EXPECT
105 Can't find string terminator "«" anywhere before EOF at - line 3.
106 ########
107 # NAME Unterminated q// with non-Latin-1 delimiter
108 BEGIN { binmode STDERR, ":utf8" }
109 use utf8;
110 q 옷
111 EXPECT
112 Can't find string terminator "옷" anywhere before EOF at - line 3.
113 ########
114 # NAME /\N{/
115 /\N{/
116 EXPECT
117 Missing right brace on \N{} or unescaped left brace after \N at - line 1, within pattern
118 Execution of - aborted due to compilation errors.
119 ########
120 # NAME map{for our *a...
121 map{for our *a (1..10) {$_.=$x}}
122 EXPECT
123 Missing $ on loop variable at - line 1.
124 ########
125 # NAME Missing name in "my sub"
126 use feature 'lexical_subs'; my sub;
127 EXPECT
128 Missing name in "my sub" at - line 1.
129 ########
130 # NAME Missing name in "our sub"
131 use feature 'lexical_subs'; our sub;
132 EXPECT
133 Missing name in "our sub" at - line 1.
134 ########
135 # NAME Missing name in "state sub"
136 use 5.01;
137 state sub;
138 EXPECT
139 Missing name in "state sub" at - line 2.
140 ########
141 # NAME our sub pack::foo
142 our sub foo::bar;
143 EXPECT
144 No package name allowed for subroutine &foo::bar in "our" at - line 1, near "our sub foo::bar"
145 Execution of - aborted due to compilation errors.
146 ########
147 # NAME my sub pack::foo
148 use feature 'lexical_subs', 'state';
149 my sub foo::bar;
150 state sub foo::bear;
151 EXPECT
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"
154 Execution of - aborted due to compilation errors.
155 ########
156 # NAME Integer constant overloading returning undef
157 use overload;
158 BEGIN { overload::constant integer => sub {}; undef *^H }
159 1
160 EXPECT
161 Constant(1) unknown at - line 3, at end of line
162 Execution of - aborted due to compilation errors.
163 ########
164 # NAME Float constant overloading returning undef
165 use overload;
166 BEGIN { overload::constant float => sub {}; undef *^H }
167 1.1
168 EXPECT
169 Constant(1.1) unknown at - line 3, at end of line
170 Execution of - aborted due to compilation errors.
171 ########
172 # NAME Binary constant overloading returning undef
173 use overload;
174 BEGIN { overload::constant binary => sub {}; undef *^H }
175 0x1
176 EXPECT
177 Constant(0x1) unknown at - line 3, at end of line
178 Execution of - aborted due to compilation errors.
179 ########
180 # NAME String constant overloading returning undef
181 use overload;
182 BEGIN { overload::constant q => sub {}; undef *^H }
183 '1', "1$_", tr"a"", s""a"
184 EXPECT
185 Constant(q) unknown at - line 3, near "'1'"
186 Constant(qq) unknown at - line 3, within string
187 Constant(tr) unknown at - line 3, within string
188 Constant(s) unknown at - line 3, within string
189 Execution of - aborted due to compilation errors.
190 ########
191 # NAME Regexp constant overloading when *^H is undefined
192 use overload;
193 BEGIN { overload::constant qr => sub {}; undef *^H }
194 /a/
195 EXPECT
196 Constant(qq) unknown at - line 3, within pattern
197 Execution of - aborted due to compilation errors.
198 ########
199 # NAME Regexp constant overloading when *^H is undefined
200 use overload;
201 BEGIN { overload::constant qr => sub {}; undef *^H }
202 m'a'
203 EXPECT
204 Constant(q) unknown at - line 3, within pattern
205 Execution 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
209 BEGIN { ++$_ for @INC{"charnames.pm","_charnames.pm"} }
210 "\N{a}"
211 EXPECT
212 Constant(\N{a}) unknown at - line 2, within string
213 Execution of - aborted due to compilation errors.
214 ########
215 # NAME Integer constant overloading returning undef
216 use overload;
217 BEGIN { overload::constant integer => sub {} }
218 1
219 EXPECT
220 Constant(1): Call to &{$^H{integer}} did not return a defined value at - line 3, at end of line
221 Execution of - aborted due to compilation errors.
222 ########
223 # NAME Float constant overloading returning undef
224 use overload;
225 BEGIN { overload::constant float => sub {} }
226 1.1
227 EXPECT
228 Constant(1.1): Call to &{$^H{float}} did not return a defined value at - line 3, at end of line
229 Execution of - aborted due to compilation errors.
230 ########
231 # NAME Binary constant overloading returning undef
232 use overload;
233 BEGIN { overload::constant binary => sub {} }
234 0x1
235 EXPECT
236 Constant(0x1): Call to &{$^H{binary}} did not return a defined value at - line 3, at end of line
237 Execution of - aborted due to compilation errors.
238 ########
239 # NAME String constant overloading returning undef
240 use overload;
241 BEGIN { overload::constant q => sub {} }
242 '1', "1$_", tr"a"", s""a"
243 EXPECT
244 Constant(q): Call to &{$^H{q}} did not return a defined value at - line 3, near "'1'"
245 Constant(qq): Call to &{$^H{q}} did not return a defined value at - line 3, within string
246 Constant(tr): Call to &{$^H{q}} did not return a defined value at - line 3, within string
247 Constant(s): Call to &{$^H{q}} did not return a defined value at - line 3, within string
248 Execution of - aborted due to compilation errors.
249 ########
250 # NAME Regexp constant overloading returning undef
251 use overload;
252 BEGIN { overload::constant qr => sub {} }
253 /a/
254 EXPECT
255 Constant(qq): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
256 Execution of - aborted due to compilation errors.
257 ########
258 # NAME Regexp constant overloading returning undef
259 use overload;
260 BEGIN { overload::constant qr => sub {} }
261 m'a'
262 EXPECT
263 Constant(q): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
264 Execution of - aborted due to compilation errors.
265 ########
266 # NAME Failed constant overloading should not cause a double free
267 use overload;
268 BEGIN { overload::constant q => sub {}; undef *^H }
269 undef(1,2);
270 undef(1,2);
271 undef(1,2);
272 undef(1,2);
273 undef(1,2);
274 undef(1,2);
275 undef(1,2);
276 undef(1,2);
277 undef(1,2);
278 "a"
279 EXPECT
280 Too many arguments for undef operator at - line 3, near "2)"
281 Too many arguments for undef operator at - line 4, near "2)"
282 Too many arguments for undef operator at - line 5, near "2)"
283 Too many arguments for undef operator at - line 6, near "2)"
284 Too many arguments for undef operator at - line 7, near "2)"
285 Too many arguments for undef operator at - line 8, near "2)"
286 Too many arguments for undef operator at - line 9, near "2)"
287 Too many arguments for undef operator at - line 10, near "2)"
288 Too many arguments for undef operator at - line 11, near "2)"
289 Constant(q) unknown at - line 12, near ""a""
290 - has too many errors.
291 ########
292 # NAME Bad name after ' (with other helpful messages)
293 sub has{}
294 has erdef => (
295     isa => 'Int',
296     is => 'ro,
297     default => sub { 1 }
298 );
299
300 has cxxc => (
301     isa => 'Int',
302     is => 'ro',
303     default => sub { 1 }
304 );
305 EXPECT
306 Bareword 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?)
309 Bad name after Int' at - line 9.
310 ########
311 # NAME Bad name after :: (with other helpful messages)
312 sub has{}
313 has erdef => (
314     isa => 'Int',
315     is => "ro,
316     default => sub { 1 }
317 );
318
319 has cxxc => (
320     isa => "Foo::$subpackage",
321     is => 'ro',
322     default => sub { 1 }
323 );
324 EXPECT
325 Bareword 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?)
328 Bad name after Foo:: at - line 9.
329 ########
330 # NAME Unterminated delimiter for here document
331 <<"foo
332 EXPECT
333 Unterminated delimiter for here document at - line 1.
334 ########
335 # NAME my (our $x) errors
336 my (our $x);
337 EXPECT
338 Can't redeclare "our" in "my" at - line 1, near "(our"
339 Execution of - aborted due to compilation errors.
340 ########
341 # NAME our (my $x) errors
342 our (my $x);
343 EXPECT
344 Can't redeclare "my" in "our" at - line 1, near "(my"
345 Execution of - aborted due to compilation errors.
346 ########
347 # NAME state (my $x) errors
348 use feature 'state';
349 state (my $x);
350 EXPECT
351 Can't redeclare "my" in "state" at - line 2, near "(my"
352 Execution of - aborted due to compilation errors.
353 ########
354 # NAME our (state $x) errors
355 use feature 'state';
356 our (state $x);
357 EXPECT
358 Can't redeclare "state" in "our" at - line 2, near "(state"
359 Execution of - aborted due to compilation errors.
360 ########
361 # NAME my (my $x) errors
362 my (my $x, $y, $z);
363 EXPECT
364 Can't redeclare "my" in "my" at - line 1, near "(my"
365 Execution of - aborted due to compilation errors.
366 ########
367 # NAME our (our $x) errors
368 our ($x, our($y), $z);
369 EXPECT
370 Can't redeclare "our" in "our" at - line 1, near ", our"
371 Execution of - aborted due to compilation errors.
372 ########
373 # NAME state (state $x) errors
374 use feature 'state';
375 state ($x, $y, state $z);
376 EXPECT
377 Can't redeclare "state" in "state" at - line 2, near ", state"
378 Execution of - aborted due to compilation errors.
379 ########
380 # NAME BEGIN <> [perl #125341]
381 BEGIN <>
382 EXPECT
383 Illegal declaration of subroutine BEGIN at - line 1.
384 ########
385 # NAME multiple conflict markers
386 <<<<<<< yours:sample.txt
387 my $some_code;
388 =======
389 my $some_other_code;
390 >>>>>>> theirs:sample.txt
391 EXPECT
392 Version control conflict marker at - line 1, near "<<<<<<<"
393 Version control conflict marker at - line 3, near "======="
394 Version control conflict marker at - line 5, near ">>>>>>>"
395 Execution of - aborted due to compilation errors.
396 ########
397 # NAME (Might be a runaway multi-line...) with Latin-1 delimiters in utf8
398 BEGIN { binmode STDERR, ':utf8' }
399 use utf8;
400
401 « time
402 EXPECT
403 syntax error at - line 4, near "« time"
404   (Might be a runaway multi-line «« string starting on line 3)
405 Execution of - aborted due to compilation errors.
406 ########
407 # NAME (Might be a runaway multi-line...) with non-Latin-1 delimiters
408 BEGIN { binmode STDERR, ':utf8' }
409 use utf8;
410 q ϡ
411 ϡ time
412 EXPECT
413 syntax error at - line 4, near "ϡ time"
414   (Might be a runaway multi-line ϡϡ string starting on line 3)
415 Execution of - aborted due to compilation errors.
416 ########
417 # NAME tr/// handling of mis-formatted \o characters
418 # may only fail with ASAN
419 tr/\o-0//;
420 EXPECT
421 Missing braces on \o{} at - line 2, within string
422 Execution of - aborted due to compilation errors.
423 ########
424 # NAME bare <<
425 $a = <<;
426
427 EXPECT
428 Use of bare << to mean <<"" is forbidden at - line 1.
429 ########
430 # NAME bare <<~
431 $a = <<~;
432 EXPECT
433 Use of bare << to mean <<"" is forbidden at - line 1.
434 ########
435 # NAME bare <<~
436 $a = <<~ ;
437
438 EXPECT
439 Use of bare << to mean <<"" is forbidden at - line 1.
440 ########
441 # NAME incomplete floating point decimal exponent (#131725)
442 1e--5
443 EXPECT
444 Bareword found where operator expected at - line 1, near "1e"
445         (Missing operator before e?)
446 Number found where operator expected at - line 1, near "--5"
447         (Missing operator before 5?)
448 syntax error at - line 1, near "1e"
449 Execution of - aborted due to compilation errors.
450 ########
451 # NAME signature with non-"=" assignop #131777
452 use feature 'signatures';
453 no warnings 'experimental::signatures';
454 sub foo ($a += 1)
455 EXPECT
456 Illegal operator following parameter in a subroutine signature at - line 3, near "($a += 1"
457 syntax error at - line 3, near "($a += 1"
458 Execution of - aborted due to compilation errors.
459 ########
460 # NAME tr/// range with empty \N{} at the start
461 tr//\N{}-0/;
462 EXPECT
463 Unknown charname '' at - line 1, within string
464 Execution of - aborted due to compilation errors.
465 ########
466 # NAME octal fp with non-octal digits after the decimal point
467 01.1234567p0;
468 07.8p0;
469 EXPECT
470 Bareword found where operator expected at - line 2, near "8p0"
471         (Missing operator before p0?)
472 syntax error at - line 2, near "8p0"
473 Execution of - aborted due to compilation errors.
474 ########
475 # NAME binary fp with non-binary digits after the decimal point
476 0b1.10p0;
477 0b1.2p0;
478 EXPECT
479 Bareword found where operator expected at - line 2, near "2p0"
480         (Missing operator before p0?)
481 syntax error at - line 2, near "2p0"
482 Execution of - aborted due to compilation errors.
483 ########
484 # NAME dump() must be written as CORE::dump() as of Perl 5.30
485 BEGIN { $^C = 1; }
486 dump;
487 CORE::dump;
488 EXPECT
489 dump() 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)
492 sub t1 {}
493 sub t2 (}
494 EXPECT
495 Prototype not terminated at - line 2.
496 ########
497 # NAME [perl #132158] format with syntax errors
498 format=
499 @
500 =h
501 =cut
502 EXPECT
503 syntax error at - line 4, next token ???
504 Execution of - aborted due to compilation errors.
505 ########
506 # NAME [perl #134045] incomplete hex number
507 0x x 2;
508 0xx 2;
509 0x_;
510 EXPECT
511 Number found where operator expected at - line 1, near "x 2"
512         (Do you need to predeclare x?)
513 Bareword found where operator expected at - line 2, near "0xx"
514         (Missing operator before xx?)
515 Number found where operator expected at - line 2, near "xx 2"
516         (Do you need to predeclare xx?)
517 Bareword found where operator expected at - line 3, near "0x_"
518         (Missing operator before x_?)
519 syntax error at - line 1, near "x 2"
520 Execution of - aborted due to compilation errors.
521 ########
522 # NAME [perl #130585] close paren in subparse
523 qr!@{s{0})(?{!;
524 EXPECT
525 syntax error at - line 1, near "})"
526 Execution of - aborted due to compilation errors.
527 ########
528 # NAME [perl #130585] close paren in subparse - a few more tests
529 my ($x, %y, @z);
530 qq!$x\U $z[0] $y{a}\E $z[1]!;
531 qq!$x\U@{s{0})(?{!;
532 EXPECT
533 syntax error at - line 3, near ")("
534 Execution of - aborted due to compilation errors.