summaryrefslogtreecommitdiff
path: root/t/lib/croak/toke
blob: 0d20acbd590f711f9f2e000b90036390cd7ce257 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
__END__
# NAME foo found where operator expected
myfunc 1,2,3
EXPECT
Number found where operator expected at - line 1, near "myfunc 1"
	(Do you need to predeclare myfunc?)
syntax error at - line 1, near "myfunc 1"
Execution of - aborted due to compilation errors.
########
# NAME foo found where operator expected (after strict error, w/fatal warnings)
use warnings FATAL => 'all';
use strict;
$foo;
myfunc 1,2,3
EXPECT
Global symbol "$foo" requires explicit package name (did you forget to declare "my $foo"?) at - line 3.
Number found where operator expected at - line 4, near "myfunc 1"
	(Do you need to predeclare myfunc?)
syntax error at - line 4, near "myfunc 1"
Execution of - aborted due to compilation errors.
########
# NAME (Missing operator before ${?) [perl #123737]
0${
EXPECT
Scalar found where operator expected at - line 1, near "0${"
	(Missing operator before ${?)
syntax error at - line 1, near "0$"
Missing right curly or square bracket at - line 1, at end of line
Execution of - aborted due to compilation errors.
########
# NAME (Missing operator before $#{?) [perl #123737]
0$#{
EXPECT
Array length found where operator expected at - line 1, near "0$#{"
	(Missing operator before $#{?)
syntax error at - line 1, near "0$#"
Missing right curly or square bracket at - line 1, at end of line
Execution of - aborted due to compilation errors.
########
# NAME (Missing operator before @foo) [perl #123737]
0@foo
EXPECT
Array found where operator expected at - line 1, near "0@foo"
	(Missing operator before @foo?)
syntax error at - line 1, near "0@foo
"
Execution of - aborted due to compilation errors.
########
# NAME (Missing operator before @{) [perl #123737]
0@{
EXPECT
Array found where operator expected at - line 1, near "0@{"
	(Missing operator before @{?)
syntax error at - line 1, near "0@"
Missing right curly or square bracket at - line 1, at end of line
Execution of - aborted due to compilation errors.
########
# NAME Unterminated here-doc in string eval
eval "<<foo"; die $@
EXPECT
Can't find string terminator "foo" anywhere before EOF at (eval 1) line 1.
########
# NAME Unterminated here-doc in s/// string eval
eval "s//<<foo/e"; die $@
EXPECT
Can't find string terminator "foo" anywhere before EOF at (eval 1) line 1.
########
# NAME Unterminated here-doc in string
"${<<foo"; # Used to give ‘Attempt to free blah blah blah’
EXPECT
Can't find string terminator "foo" anywhere before EOF at - line 1.
########
# NAME Unterminated here-doc with non-Latin-1 terminator
BEGIN { binmode STDERR, ":utf8" }
use utf8;
<<옷옷
EXPECT
Can't find string terminator "옷옷" anywhere before EOF at - line 3.
########
# NAME Unterminated qw//
qw/
EXPECT
Can't find string terminator "/" anywhere before EOF at - line 1.
########
# NAME Unterminated q//
qw/
EXPECT
Can't find string terminator "/" anywhere before EOF at - line 1.
########
# NAME Unterminated ''
'
EXPECT
Can't find string terminator "'" anywhere before EOF at - line 1.
########
# NAME Unterminated ""
"
EXPECT
Can't find string terminator '"' anywhere before EOF at - line 1.
########
# NAME Unterminated q// with non-ASCII delimiter, under utf8
BEGIN { binmode STDERR, ":utf8" }
use utf8;
q«
EXPECT
Can't find string terminator "«" anywhere before EOF at - line 3.
########
# NAME Unterminated q// with non-Latin-1 delimiter
BEGIN { binmode STDERR, ":utf8" }
use utf8;
q 옷
EXPECT
Can't find string terminator "옷" anywhere before EOF at - line 3.
########
# NAME /\N{/
/\N{/
EXPECT
Missing right brace on \N{} or unescaped left brace after \N at - line 1, within pattern
Execution of - aborted due to compilation errors.
########
# NAME map{for our *a...
map{for our *a (1..10) {$_.=$x}}
EXPECT
Missing $ on loop variable at - line 1.
########
# NAME Missing name in "my sub"
use feature 'lexical_subs'; my sub;
EXPECT
Missing name in "my sub" at - line 1.
########
# NAME Missing name in "our sub"
use feature 'lexical_subs'; our sub;
EXPECT
Missing name in "our sub" at - line 1.
########
# NAME Missing name in "state sub"
use 5.01;
state sub;
EXPECT
Missing name in "state sub" at - line 2.
########
# NAME our sub pack::foo
our sub foo::bar;
EXPECT
No package name allowed for subroutine &foo::bar in "our" at - line 1, near "our sub foo::bar"
Execution of - aborted due to compilation errors.
########
# NAME my sub pack::foo
use feature 'lexical_subs', 'state';
my sub foo::bar;
state sub foo::bear;
EXPECT
"my" subroutine &foo::bar can't be in a package at - line 2, near "my sub foo::bar"
"state" subroutine &foo::bear can't be in a package at - line 3, near "state sub foo::bear"
Execution of - aborted due to compilation errors.
########
# NAME Integer constant overloading returning undef
use overload;
BEGIN { overload::constant integer => sub {}; undef *^H }
1
EXPECT
Constant(1) unknown at - line 3, at end of line
Execution of - aborted due to compilation errors.
########
# NAME Float constant overloading returning undef
use overload;
BEGIN { overload::constant float => sub {}; undef *^H }
1.1
EXPECT
Constant(1.1) unknown at - line 3, at end of line
Execution of - aborted due to compilation errors.
########
# NAME Binary constant overloading returning undef
use overload;
BEGIN { overload::constant binary => sub {}; undef *^H }
0x1
EXPECT
Constant(0x1) unknown at - line 3, at end of line
Execution of - aborted due to compilation errors.
########
# NAME String constant overloading returning undef
use overload;
BEGIN { overload::constant q => sub {}; undef *^H }
'1', "1$_", tr"a"", s""a"
EXPECT
Constant(q) unknown at - line 3, near "'1'"
Constant(qq) unknown at - line 3, within string
Constant(tr) unknown at - line 3, within string
Constant(s) unknown at - line 3, within string
Execution of - aborted due to compilation errors.
########
# NAME Regexp constant overloading when *^H is undefined
use overload;
BEGIN { overload::constant qr => sub {}; undef *^H }
/a/
EXPECT
Constant(qq) unknown at - line 3, within pattern
Execution of - aborted due to compilation errors.
########
# NAME Regexp constant overloading when *^H is undefined
use overload;
BEGIN { overload::constant qr => sub {}; undef *^H }
m'a'
EXPECT
Constant(q) unknown at - line 3, within pattern
Execution of - aborted due to compilation errors.
########
# NAME \N{...} when charnames fails to load but without an error
# SKIP ? exists $ENV{PERL_UNICODE} ? "Unreliable under some PERL_UNICODE settings" : 0
BEGIN { ++$_ for @INC{"charnames.pm","_charnames.pm"} }
"\N{a}"
EXPECT
Constant(\N{a}) unknown at - line 2, within string
Execution of - aborted due to compilation errors.
########
# NAME Integer constant overloading returning undef
use overload;
BEGIN { overload::constant integer => sub {} }
1
EXPECT
Constant(1): Call to &{$^H{integer}} did not return a defined value at - line 3, at end of line
Execution of - aborted due to compilation errors.
########
# NAME Float constant overloading returning undef
use overload;
BEGIN { overload::constant float => sub {} }
1.1
EXPECT
Constant(1.1): Call to &{$^H{float}} did not return a defined value at - line 3, at end of line
Execution of - aborted due to compilation errors.
########
# NAME Binary constant overloading returning undef
use overload;
BEGIN { overload::constant binary => sub {} }
0x1
EXPECT
Constant(0x1): Call to &{$^H{binary}} did not return a defined value at - line 3, at end of line
Execution of - aborted due to compilation errors.
########
# NAME String constant overloading returning undef
use overload;
BEGIN { overload::constant q => sub {} }
'1', "1$_", tr"a"", s""a"
EXPECT
Constant(q): Call to &{$^H{q}} did not return a defined value at - line 3, near "'1'"
Constant(qq): Call to &{$^H{q}} did not return a defined value at - line 3, within string
Constant(tr): Call to &{$^H{q}} did not return a defined value at - line 3, within string
Constant(s): Call to &{$^H{q}} did not return a defined value at - line 3, within string
Execution of - aborted due to compilation errors.
########
# NAME Regexp constant overloading returning undef
use overload;
BEGIN { overload::constant qr => sub {} }
/a/
EXPECT
Constant(qq): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
Execution of - aborted due to compilation errors.
########
# NAME Regexp constant overloading returning undef
use overload;
BEGIN { overload::constant qr => sub {} }
m'a'
EXPECT
Constant(q): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
Execution of - aborted due to compilation errors.
########
# NAME Failed constant overloading should not cause a double free
use overload;
BEGIN { overload::constant q => sub {}; undef *^H }
undef(1,2);
undef(1,2);
undef(1,2);
undef(1,2);
undef(1,2);
undef(1,2);
undef(1,2);
undef(1,2);
undef(1,2);
"a"
EXPECT
Too many arguments for undef operator at - line 3, near "2)"
Too many arguments for undef operator at - line 4, near "2)"
Too many arguments for undef operator at - line 5, near "2)"
Too many arguments for undef operator at - line 6, near "2)"
Too many arguments for undef operator at - line 7, near "2)"
Too many arguments for undef operator at - line 8, near "2)"
Too many arguments for undef operator at - line 9, near "2)"
Too many arguments for undef operator at - line 10, near "2)"
Too many arguments for undef operator at - line 11, near "2)"
Constant(q) unknown at - line 12, near ""a""
- has too many errors.
########
# NAME Bad name after ' (with other helpful messages)
sub has{}
has erdef => (
    isa => 'Int',
    is => 'ro,
    default => sub { 1 }
);

has cxxc => (
    isa => 'Int',
    is => 'ro',
    default => sub { 1 }
);
EXPECT
Bareword found where operator expected at - line 9, near "isa => 'Int"
  (Might be a runaway multi-line '' string starting on line 4)
	(Do you need to predeclare isa?)
Bad name after Int' at - line 9.
########
# NAME Bad name after :: (with other helpful messages)
sub has{}
has erdef => (
    isa => 'Int',
    is => "ro,
    default => sub { 1 }
);

has cxxc => (
    isa => "Foo::$subpackage",
    is => 'ro',
    default => sub { 1 }
);
EXPECT
Bareword found where operator expected at - line 9, near "isa => "Foo"
  (Might be a runaway multi-line "" string starting on line 4)
	(Do you need to predeclare isa?)
Bad name after Foo:: at - line 9.
########
# NAME Unterminated delimiter for here document
<<"foo
EXPECT
Unterminated delimiter for here document at - line 1.
########
# NAME my (our $x) errors
my (our $x);
EXPECT
Can't redeclare "our" in "my" at - line 1, near "(our"
Execution of - aborted due to compilation errors.
########
# NAME our (my $x) errors
our (my $x);
EXPECT
Can't redeclare "my" in "our" at - line 1, near "(my"
Execution of - aborted due to compilation errors.
########
# NAME state (my $x) errors
use feature 'state';
state (my $x);
EXPECT
Can't redeclare "my" in "state" at - line 2, near "(my"
Execution of - aborted due to compilation errors.
########
# NAME our (state $x) errors
use feature 'state';
our (state $x);
EXPECT
Can't redeclare "state" in "our" at - line 2, near "(state"
Execution of - aborted due to compilation errors.
########
# NAME my (my $x) errors
my (my $x, $y, $z);
EXPECT
Can't redeclare "my" in "my" at - line 1, near "(my"
Execution of - aborted due to compilation errors.
########
# NAME our (our $x) errors
our ($x, our($y), $z);
EXPECT
Can't redeclare "our" in "our" at - line 1, near ", our"
Execution of - aborted due to compilation errors.
########
# NAME state (state $x) errors
use feature 'state';
state ($x, $y, state $z);
EXPECT
Can't redeclare "state" in "state" at - line 2, near ", state"
Execution of - aborted due to compilation errors.
########
# NAME BEGIN <> [perl #125341]
BEGIN <>
EXPECT
Illegal declaration of subroutine BEGIN at - line 1.
########
# NAME multiple conflict markers
<<<<<<< yours:sample.txt
my $some_code;
=======
my $some_other_code;
>>>>>>> theirs:sample.txt
EXPECT
Version control conflict marker at - line 1, near "<<<<<<<"
Version control conflict marker at - line 3, near "======="
Version control conflict marker at - line 5, near ">>>>>>>"
Execution of - aborted due to compilation errors.
########
# NAME (Might be a runaway multi-line...) with Latin-1 delimiters in utf8
BEGIN { binmode STDERR, ':utf8' }
use utf8;
q«
« time
EXPECT
syntax error at - line 4, near "« time"
  (Might be a runaway multi-line «« string starting on line 3)
Execution of - aborted due to compilation errors.
########
# NAME (Might be a runaway multi-line...) with non-Latin-1 delimiters
BEGIN { binmode STDERR, ':utf8' }
use utf8;
q ϡ
ϡ time
EXPECT
syntax error at - line 4, near "ϡ time"
  (Might be a runaway multi-line ϡϡ string starting on line 3)
Execution of - aborted due to compilation errors.
########
# NAME tr/// handling of mis-formatted \o characters
# may only fail with ASAN
tr/\o-0//;
EXPECT
Missing braces on \o{} at - line 2, within string
Execution of - aborted due to compilation errors.
########
# NAME bare <<
$a = <<;

EXPECT
Use of bare << to mean <<"" is forbidden at - line 1.
########
# NAME bare <<~
$a = <<~;
EXPECT
Use of bare << to mean <<"" is forbidden at - line 1.
########
# NAME bare <<~
$a = <<~ ;

EXPECT
Use of bare << to mean <<"" is forbidden at - line 1.
########
# NAME incomplete floating point decimal exponent (#131725)
1e--5
EXPECT
Bareword found where operator expected at - line 1, near "1e"
	(Missing operator before e?)
Number found where operator expected at - line 1, near "--5"
	(Missing operator before 5?)
syntax error at - line 1, near "1e"
Execution of - aborted due to compilation errors.
########
# NAME signature with non-"=" assignop #131777
use feature 'signatures';
no warnings 'experimental::signatures';
sub foo ($a += 1)
EXPECT
Illegal operator following parameter in a subroutine signature at - line 3, near "($a += 1"
syntax error at - line 3, near "($a += 1"
Execution of - aborted due to compilation errors.
########
# NAME tr/// range with empty \N{} at the start
tr//\N{}-0/;
EXPECT
Unknown charname '' at - line 1, within string
Execution of - aborted due to compilation errors.
########
# NAME octal fp with non-octal digits after the decimal point
01.1234567p0;
07.8p0;
EXPECT
Bareword found where operator expected at - line 2, near "8p0"
	(Missing operator before p0?)
syntax error at - line 2, near "8p0"
Execution of - aborted due to compilation errors.
########
# NAME binary fp with non-binary digits after the decimal point
0b1.10p0;
0b1.2p0;
EXPECT
Bareword found where operator expected at - line 2, near "2p0"
	(Missing operator before p0?)
syntax error at - line 2, near "2p0"
Execution of - aborted due to compilation errors.
########
# NAME dump() must be written as CORE::dump() as of Perl 5.30
BEGIN { $^C = 1; }
dump;
CORE::dump;
EXPECT
dump() must be written as CORE::dump() as of Perl 5.30 at - line 2.
########
# NAME check Prototype not terminated includes line number (133524)
sub t1 {}
sub t2 (}
EXPECT
Prototype not terminated at - line 2.
########
# NAME [perl #132158] format with syntax errors
format=
@
=h
=cut
EXPECT
syntax error at - line 4, next token ???
Execution of - aborted due to compilation errors.
########
# NAME [perl #134045] incomplete hex number
0x x 2;
0xx 2;
0x_;
0b;
EXPECT
No digits found for hexadecimal literal at - line 1, near "0x "
No digits found for hexadecimal literal at - line 2, near "0xx"
No digits found for hexadecimal literal at - line 3, near "0x_;"
No digits found for binary literal at - line 4, near "0b;"
Execution of - aborted due to compilation errors.
########
# NAME [perl #130585] close paren in subparse
qr!@{s{0})(?{!;
EXPECT
syntax error at - line 1, near "})"
Execution of - aborted due to compilation errors.
########
# NAME [perl #130585] close paren in subparse - a few more tests
my ($x, %y, @z);
qq!$x\U $z[0] $y{a}\E $z[1]!;
qq!$x\U@{s{0})(?{!;
EXPECT
syntax error at - line 3, near ")("
Execution of - aborted due to compilation errors.
########
# NAME [perl #134310] don't confuse S_no_op() with PL_bufptr after s
0 0x@
EXPECT
Number found where operator expected at - line 1, near "0 0x"
	(Missing operator before  0x?)
Array found where operator expected at - line 1, near "0x@
;"
	(Missing operator before ;?)
No digits found for hexadecimal literal at - line 1, near "0 0x@"
syntax error at - line 1, near "0 0x"
Execution of - aborted due to compilation errors.
########
# NAME Forbid illegal \x{} code points
use Config;
if ($Config{uvsize} < 8) {
    my $a = "\x{8000_0000}";
}
else {
    my $a = "\x{8000_0000_0000_0000}";
}
EXPECT
OPTIONS regex
Use of code point 0x80000000(00000000)? is not allowed; the permissible max is 0x7FFFFFFF(FFFFFFFF)? at - line \d+.
########
# NAME Forbid illegal \o{} code points
use Config;
if ($Config{uvsize} < 8) {
    my $b = "\o{20_000_000_000}";
}
else {
    my $b = "\o{1_000_000_000_000_000_000_000}";
}
EXPECT
OPTIONS regex
Use of code point 0x80000000(00000000)? is not allowed; the permissible max is 0x7FFFFFFF(FFFFFFFF)? at - line \d+.
########
# NAME gh-17645: conflict marker detection should not read out of bounds
m/$0[
==0/
EXPECT
syntax error at - line 2, near "[
=="
  (Might be a runaway multi-line // string starting on line 1)
Execution of - aborted due to compilation errors.