This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(perl #132245) don't try to process a char range with no preceding char
[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########
cb650135
FC
95# NAME Unterminated q// with non-ASCII delimiter, under utf8
96BEGIN { binmode STDERR, ":utf8" }
97use utf8;
98
99EXPECT
100Can't find string terminator "«" anywhere before EOF at - line 3.
101########
102# NAME Unterminated q// with non-Latin-1 delimiter
103BEGIN { binmode STDERR, ":utf8" }
104use utf8;
105q 옷
106EXPECT
107Can't find string terminator "옷" anywhere before EOF at - line 3.
108########
4407f1b8
FC
109# NAME /\N{/
110/\N{/
111EXPECT
112Missing right brace on \N{} or unescaped left brace after \N at - line 1, within pattern
ca53e5d5 113Execution of - aborted due to compilation errors.
4407f1b8 114########
e660c409
FC
115# NAME map{for our *a...
116map{for our *a (1..10) {$_.=$x}}
117EXPECT
118Missing $ on loop variable at - line 1.
119########
ca8ffed2 120# NAME Missing name in "my sub"
e7d0b801 121use feature 'lexical_subs'; my sub;
ca8ffed2
FC
122EXPECT
123Missing name in "my sub" at - line 1.
6f2d7fc9 124########
8767b1ab 125# NAME Missing name in "our sub"
e7d0b801 126use feature 'lexical_subs'; our sub;
8767b1ab
FC
127EXPECT
128Missing name in "our sub" at - line 1.
129########
130# NAME Missing name in "state sub"
60e04ba1 131use 5.01;
8767b1ab
FC
132state sub;
133EXPECT
134Missing name in "state sub" at - line 2.
135########
b9a58d50
FC
136# NAME our sub pack::foo
137our sub foo::bar;
138EXPECT
139No package name allowed for subroutine &foo::bar in "our" at - line 1, near "our sub foo::bar"
140Execution of - aborted due to compilation errors.
141########
a21eb52b
FC
142# NAME my sub pack::foo
143use feature 'lexical_subs', 'state';
144my sub foo::bar;
145state sub foo::bear;
146EXPECT
a21eb52b
FC
147"my" subroutine &foo::bar can't be in a package at - line 2, near "my sub foo::bar"
148"state" subroutine &foo::bear can't be in a package at - line 3, near "state sub foo::bear"
149Execution of - aborted due to compilation errors.
150########
b2e3d01a
FC
151# NAME Integer constant overloading returning undef
152use overload;
247a7f40
FC
153BEGIN { overload::constant integer => sub {}; undef *^H }
1541
155EXPECT
bb4784f0 156Constant(1) unknown at - line 3, at end of line
247a7f40
FC
157Execution of - aborted due to compilation errors.
158########
159# NAME Float constant overloading returning undef
160use overload;
161BEGIN { overload::constant float => sub {}; undef *^H }
1621.1
163EXPECT
bb4784f0 164Constant(1.1) unknown at - line 3, at end of line
247a7f40
FC
165Execution of - aborted due to compilation errors.
166########
167# NAME Binary constant overloading returning undef
168use overload;
169BEGIN { overload::constant binary => sub {}; undef *^H }
1700x1
171EXPECT
bb4784f0 172Constant(0x1) unknown at - line 3, at end of line
247a7f40
FC
173Execution of - aborted due to compilation errors.
174########
175# NAME String constant overloading returning undef
176use overload;
177BEGIN { overload::constant q => sub {}; undef *^H }
178'1', "1$_", tr"a"", s""a"
179EXPECT
180Constant(q) unknown at - line 3, near "'1'"
181Constant(qq) unknown at - line 3, within string
182Constant(tr) unknown at - line 3, within string
183Constant(s) unknown at - line 3, within string
184Execution of - aborted due to compilation errors.
185########
186# NAME Regexp constant overloading when *^H is undefined
187use overload;
188BEGIN { overload::constant qr => sub {}; undef *^H }
efa571ab 189/a/
247a7f40
FC
190EXPECT
191Constant(qq) unknown at - line 3, within pattern
efa571ab
KW
192Execution of - aborted due to compilation errors.
193########
194# NAME Regexp constant overloading when *^H is undefined
195use overload;
196BEGIN { overload::constant qr => sub {}; undef *^H }
197m'a'
198EXPECT
247a7f40
FC
199Constant(q) unknown at - line 3, within pattern
200Execution of - aborted due to compilation errors.
201########
202# NAME \N{...} when charnames fails to load but without an error
d4ead2eb 203# SKIP ? exists $ENV{PERL_UNICODE} ? "Unreliable under some PERL_UNICODE settings" : 0
247a7f40
FC
204BEGIN { ++$_ for @INC{"charnames.pm","_charnames.pm"} }
205"\N{a}"
206EXPECT
207Constant(\N{a}) unknown at - line 2, within string
208Execution of - aborted due to compilation errors.
209########
210# NAME Integer constant overloading returning undef
211use overload;
b2e3d01a
FC
212BEGIN { overload::constant integer => sub {} }
2131
214EXPECT
bb4784f0 215Constant(1): Call to &{$^H{integer}} did not return a defined value at - line 3, at end of line
b2e3d01a
FC
216Execution of - aborted due to compilation errors.
217########
218# NAME Float constant overloading returning undef
219use overload;
220BEGIN { overload::constant float => sub {} }
2211.1
222EXPECT
bb4784f0 223Constant(1.1): Call to &{$^H{float}} did not return a defined value at - line 3, at end of line
b2e3d01a
FC
224Execution of - aborted due to compilation errors.
225########
226# NAME Binary constant overloading returning undef
227use overload;
228BEGIN { overload::constant binary => sub {} }
2290x1
230EXPECT
bb4784f0 231Constant(0x1): Call to &{$^H{binary}} did not return a defined value at - line 3, at end of line
b2e3d01a
FC
232Execution of - aborted due to compilation errors.
233########
234# NAME String constant overloading returning undef
235use overload;
236BEGIN { overload::constant q => sub {} }
237'1', "1$_", tr"a"", s""a"
238EXPECT
239Constant(q): Call to &{$^H{q}} did not return a defined value at - line 3, near "'1'"
240Constant(qq): Call to &{$^H{q}} did not return a defined value at - line 3, within string
241Constant(tr): Call to &{$^H{q}} did not return a defined value at - line 3, within string
242Constant(s): Call to &{$^H{q}} did not return a defined value at - line 3, within string
243Execution of - aborted due to compilation errors.
244########
245# NAME Regexp constant overloading returning undef
246use overload;
247BEGIN { overload::constant qr => sub {} }
efa571ab 248/a/
b2e3d01a
FC
249EXPECT
250Constant(qq): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
efa571ab
KW
251Execution of - aborted due to compilation errors.
252########
253# NAME Regexp constant overloading returning undef
254use overload;
255BEGIN { overload::constant qr => sub {} }
256m'a'
257EXPECT
b2e3d01a
FC
258Constant(q): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
259Execution of - aborted due to compilation errors.
260########
67c71cbb
FC
261# NAME Failed constant overloading should not cause a double free
262use overload;
263BEGIN { overload::constant q => sub {}; undef *^H }
264undef(1,2);
265undef(1,2);
266undef(1,2);
267undef(1,2);
268undef(1,2);
269undef(1,2);
270undef(1,2);
271undef(1,2);
272undef(1,2);
273"a"
274EXPECT
275Too many arguments for undef operator at - line 3, near "2)"
276Too many arguments for undef operator at - line 4, near "2)"
277Too many arguments for undef operator at - line 5, near "2)"
278Too many arguments for undef operator at - line 6, near "2)"
279Too many arguments for undef operator at - line 7, near "2)"
280Too many arguments for undef operator at - line 8, near "2)"
281Too many arguments for undef operator at - line 9, near "2)"
282Too many arguments for undef operator at - line 10, near "2)"
283Too many arguments for undef operator at - line 11, near "2)"
284Constant(q) unknown at - line 12, near ""a""
285- has too many errors.
286########
6f2d7fc9
FC
287# NAME Unterminated delimiter for here document
288<<"foo
289EXPECT
290Unterminated delimiter for here document at - line 1.
f3106bc8
LM
291########
292# NAME my (our $x) errors
293my (our $x);
294EXPECT
37808b00 295Can't redeclare "our" in "my" at - line 1, near "(our"
f3106bc8
LM
296Execution of - aborted due to compilation errors.
297########
298# NAME our (my $x) errors
299our (my $x);
300EXPECT
37808b00 301Can't redeclare "my" in "our" at - line 1, near "(my"
f3106bc8
LM
302Execution of - aborted due to compilation errors.
303########
304# NAME state (my $x) errors
305use feature 'state';
306state (my $x);
307EXPECT
37808b00 308Can't redeclare "my" in "state" at - line 2, near "(my"
f3106bc8
LM
309Execution of - aborted due to compilation errors.
310########
311# NAME our (state $x) errors
312use feature 'state';
313our (state $x);
314EXPECT
37808b00 315Can't redeclare "state" in "our" at - line 2, near "(state"
f3106bc8
LM
316Execution of - aborted due to compilation errors.
317########
318# NAME my (my $x) errors
319my (my $x, $y, $z);
320EXPECT
37808b00 321Can't redeclare "my" in "my" at - line 1, near "(my"
f3106bc8
LM
322Execution of - aborted due to compilation errors.
323########
324# NAME our (our $x) errors
325our ($x, our($y), $z);
326EXPECT
37808b00 327Can't redeclare "our" in "our" at - line 1, near ", our"
f3106bc8
LM
328Execution of - aborted due to compilation errors.
329########
330# NAME state (state $x) errors
331use feature 'state';
332state ($x, $y, state $z);
333EXPECT
37808b00 334Can't redeclare "state" in "state" at - line 2, near ", state"
f3106bc8 335Execution of - aborted due to compilation errors.
e6b2cf83
TC
336########
337# NAME BEGIN <> [perl #125341]
338BEGIN <>
339EXPECT
340Illegal declaration of subroutine BEGIN at - line 1.
e2733f9a
TC
341########
342# NAME multiple conflict markers
343<<<<<<< yours:sample.txt
344my $some_code;
345=======
346my $some_other_code;
347>>>>>>> theirs:sample.txt
348EXPECT
349Version control conflict marker at - line 1, near "<<<<<<<"
350Version control conflict marker at - line 3, near "======="
351Version control conflict marker at - line 5, near ">>>>>>>"
352Execution of - aborted due to compilation errors.
a3164817
FC
353########
354# NAME (Might be a runaway multi-line...) with Latin-1 delimiters in utf8
355BEGIN { binmode STDERR, ':utf8' }
356use utf8;
357
358« time
359EXPECT
360syntax error at - line 4, near "« time"
361 (Might be a runaway multi-line «« string starting on line 3)
362Execution of - aborted due to compilation errors.
363########
364# NAME (Might be a runaway multi-line...) with non-Latin-1 delimiters
365BEGIN { binmode STDERR, ':utf8' }
366use utf8;
367q ϡ
368ϡ time
369EXPECT
370syntax error at - line 4, near "ϡ time"
371 (Might be a runaway multi-line ϡϡ string starting on line 3)
372Execution of - aborted due to compilation errors.
59143e29
TC
373########
374# NAME tr/// handling of mis-formatted \o characters
375# may only fail with ASAN
376tr/\o-0//;
377EXPECT
378Missing braces on \o{} at - line 2, within string
379Execution of - aborted due to compilation errors.
c6e25b09
DIM
380########
381# NAME bare <<
382$a = <<;
383
384EXPECT
385Use of bare << to mean <<"" is forbidden at - line 1.
386########
387# NAME bare <<~
388$a = <<~;
389EXPECT
390Use of bare << to mean <<"" is forbidden at - line 1.
391########
392# NAME bare <<~
393$a = <<~ ;
394
395EXPECT
396Use of bare << to mean <<"" is forbidden at - line 1.
adb0f5c4
TC
397########
398# NAME incomplete floating point decimal exponent (#131725)
3991e--5
400EXPECT
401Bareword found where operator expected at - line 1, near "1e"
402 (Missing operator before e?)
403Number found where operator expected at - line 1, near "--5"
404 (Missing operator before 5?)
405syntax error at - line 1, near "1e"
406Execution of - aborted due to compilation errors.
08ccc810
TC
407########
408# NAME signature with non-"=" assignop #131777
409use feature 'signatures';
410no warnings 'experimental::signatures';
411sub foo ($a += 1)
412EXPECT
413Illegal operator following parameter in a subroutine signature at - line 3, near "($a += 1"
414syntax error at - line 3, near "($a += 1"
415Execution of - aborted due to compilation errors.
e8d55f27
TC
416########
417# NAME tr/// range with empty \N{} at the start
418tr//\N{}-0/;
419EXPECT
420Unknown charname '' at - line 1, within string
421Execution of - aborted due to compilation errors.