This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
limit digits based on radix for oct/bin fp
[perl5.git] / t / lib / croak / toke
CommitLineData
ca8ffed2 1__END__
b255a112
FC
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########
488bc579
FC
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########
310a0d0a
DM
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########
61d30259 40# NAME (Missing operator before @foo) [perl #123737]
a7162bf7
TC
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########
61d30259
TC
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########
5af08aed
FC
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########
fd2709db
FC
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########
7f7f7d08
FC
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########
20ed5f00
FC
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########
1b8d3e0e
LM
95# NAME Unterminated ""
96"
97EXPECT
98Can't find string terminator '"' anywhere before EOF at - line 1.
99########
cb650135
FC
100# NAME Unterminated q// with non-ASCII delimiter, under utf8
101BEGIN { binmode STDERR, ":utf8" }
102use utf8;
103
104EXPECT
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########
4407f1b8
FC
114# NAME /\N{/
115/\N{/
116EXPECT
117Missing right brace on \N{} or unescaped left brace after \N at - line 1, within pattern
ca53e5d5 118Execution of - aborted due to compilation errors.
4407f1b8 119########
e660c409
FC
120# NAME map{for our *a...
121map{for our *a (1..10) {$_.=$x}}
122EXPECT
123Missing $ on loop variable at - line 1.
124########
ca8ffed2 125# NAME Missing name in "my sub"
e7d0b801 126use feature 'lexical_subs'; my sub;
ca8ffed2
FC
127EXPECT
128Missing name in "my sub" at - line 1.
6f2d7fc9 129########
8767b1ab 130# NAME Missing name in "our sub"
e7d0b801 131use feature 'lexical_subs'; our sub;
8767b1ab
FC
132EXPECT
133Missing name in "our sub" at - line 1.
134########
135# NAME Missing name in "state sub"
60e04ba1 136use 5.01;
8767b1ab
FC
137state sub;
138EXPECT
139Missing name in "state sub" at - line 2.
140########
b9a58d50
FC
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########
a21eb52b
FC
147# NAME my sub pack::foo
148use feature 'lexical_subs', 'state';
149my sub foo::bar;
150state sub foo::bear;
151EXPECT
a21eb52b
FC
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########
b2e3d01a
FC
156# NAME Integer constant overloading returning undef
157use overload;
247a7f40
FC
158BEGIN { overload::constant integer => sub {}; undef *^H }
1591
160EXPECT
bb4784f0 161Constant(1) unknown at - line 3, at end of line
247a7f40
FC
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
bb4784f0 169Constant(1.1) unknown at - line 3, at end of line
247a7f40
FC
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
bb4784f0 177Constant(0x1) unknown at - line 3, at end of line
247a7f40
FC
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 }
efa571ab 194/a/
247a7f40
FC
195EXPECT
196Constant(qq) unknown at - line 3, within pattern
efa571ab
KW
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
247a7f40
FC
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
d4ead2eb 208# SKIP ? exists $ENV{PERL_UNICODE} ? "Unreliable under some PERL_UNICODE settings" : 0
247a7f40
FC
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;
b2e3d01a
FC
217BEGIN { overload::constant integer => sub {} }
2181
219EXPECT
bb4784f0 220Constant(1): Call to &{$^H{integer}} did not return a defined value at - line 3, at end of line
b2e3d01a
FC
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
bb4784f0 228Constant(1.1): Call to &{$^H{float}} did not return a defined value at - line 3, at end of line
b2e3d01a
FC
229Execution of - aborted due to compilation errors.
230########
231# NAME Binary constant overloading returning undef
232use overload;
233BEGIN { overload::constant binary => sub {} }
2340x1
235EXPECT
bb4784f0 236Constant(0x1): Call to &{$^H{binary}} did not return a defined value at - line 3, at end of line
b2e3d01a
FC
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 {} }
efa571ab 253/a/
b2e3d01a
FC
254EXPECT
255Constant(qq): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
efa571ab
KW
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
b2e3d01a
FC
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########
67c71cbb
FC
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########
76b35304
FC
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########
6f2d7fc9
FC
330# NAME Unterminated delimiter for here document
331<<"foo
332EXPECT
333Unterminated delimiter for here document at - line 1.
f3106bc8
LM
334########
335# NAME my (our $x) errors
336my (our $x);
337EXPECT
37808b00 338Can't redeclare "our" in "my" at - line 1, near "(our"
f3106bc8
LM
339Execution of - aborted due to compilation errors.
340########
341# NAME our (my $x) errors
342our (my $x);
343EXPECT
37808b00 344Can't redeclare "my" in "our" at - line 1, near "(my"
f3106bc8
LM
345Execution of - aborted due to compilation errors.
346########
347# NAME state (my $x) errors
348use feature 'state';
349state (my $x);
350EXPECT
37808b00 351Can't redeclare "my" in "state" at - line 2, near "(my"
f3106bc8
LM
352Execution of - aborted due to compilation errors.
353########
354# NAME our (state $x) errors
355use feature 'state';
356our (state $x);
357EXPECT
37808b00 358Can't redeclare "state" in "our" at - line 2, near "(state"
f3106bc8
LM
359Execution of - aborted due to compilation errors.
360########
361# NAME my (my $x) errors
362my (my $x, $y, $z);
363EXPECT
37808b00 364Can't redeclare "my" in "my" at - line 1, near "(my"
f3106bc8
LM
365Execution of - aborted due to compilation errors.
366########
367# NAME our (our $x) errors
368our ($x, our($y), $z);
369EXPECT
37808b00 370Can't redeclare "our" in "our" at - line 1, near ", our"
f3106bc8
LM
371Execution of - aborted due to compilation errors.
372########
373# NAME state (state $x) errors
374use feature 'state';
375state ($x, $y, state $z);
376EXPECT
37808b00 377Can't redeclare "state" in "state" at - line 2, near ", state"
f3106bc8 378Execution of - aborted due to compilation errors.
e6b2cf83
TC
379########
380# NAME BEGIN <> [perl #125341]
381BEGIN <>
382EXPECT
383Illegal declaration of subroutine BEGIN at - line 1.
e2733f9a
TC
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.
a3164817
FC
396########
397# NAME (Might be a runaway multi-line...) with Latin-1 delimiters in utf8
398BEGIN { binmode STDERR, ':utf8' }
399use utf8;
400
401« 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.
59143e29
TC
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.
c6e25b09
DIM
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.
adb0f5c4
TC
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.
08ccc810
TC
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.
e8d55f27
TC
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.
58be5763
TC
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.