This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
mg.c: PL_hints is unsigned
[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########
a21eb52b
FC
136# NAME my sub pack::foo
137use feature 'lexical_subs', 'state';
138my sub foo::bar;
139state sub foo::bear;
140EXPECT
a21eb52b
FC
141"my" subroutine &foo::bar can't be in a package at - line 2, near "my sub foo::bar"
142"state" subroutine &foo::bear can't be in a package at - line 3, near "state sub foo::bear"
143Execution of - aborted due to compilation errors.
144########
b2e3d01a
FC
145# NAME Integer constant overloading returning undef
146use overload;
247a7f40
FC
147BEGIN { overload::constant integer => sub {}; undef *^H }
1481
149EXPECT
bb4784f0 150Constant(1) unknown at - line 3, at end of line
247a7f40
FC
151Execution of - aborted due to compilation errors.
152########
153# NAME Float constant overloading returning undef
154use overload;
155BEGIN { overload::constant float => sub {}; undef *^H }
1561.1
157EXPECT
bb4784f0 158Constant(1.1) unknown at - line 3, at end of line
247a7f40
FC
159Execution of - aborted due to compilation errors.
160########
161# NAME Binary constant overloading returning undef
162use overload;
163BEGIN { overload::constant binary => sub {}; undef *^H }
1640x1
165EXPECT
bb4784f0 166Constant(0x1) unknown at - line 3, at end of line
247a7f40
FC
167Execution of - aborted due to compilation errors.
168########
169# NAME String constant overloading returning undef
170use overload;
171BEGIN { overload::constant q => sub {}; undef *^H }
172'1', "1$_", tr"a"", s""a"
173EXPECT
174Constant(q) unknown at - line 3, near "'1'"
175Constant(qq) unknown at - line 3, within string
176Constant(tr) unknown at - line 3, within string
177Constant(s) unknown at - line 3, within string
178Execution of - aborted due to compilation errors.
179########
180# NAME Regexp constant overloading when *^H is undefined
181use overload;
182BEGIN { overload::constant qr => sub {}; undef *^H }
183/a/, m'a'
184EXPECT
185Constant(qq) unknown at - line 3, within pattern
186Constant(q) unknown at - line 3, within pattern
187Execution of - aborted due to compilation errors.
188########
189# NAME \N{...} when charnames fails to load but without an error
d4ead2eb 190# SKIP ? exists $ENV{PERL_UNICODE} ? "Unreliable under some PERL_UNICODE settings" : 0
247a7f40
FC
191BEGIN { ++$_ for @INC{"charnames.pm","_charnames.pm"} }
192"\N{a}"
193EXPECT
194Constant(\N{a}) unknown at - line 2, within string
195Execution of - aborted due to compilation errors.
196########
197# NAME Integer constant overloading returning undef
198use overload;
b2e3d01a
FC
199BEGIN { overload::constant integer => sub {} }
2001
201EXPECT
bb4784f0 202Constant(1): Call to &{$^H{integer}} did not return a defined value at - line 3, at end of line
b2e3d01a
FC
203Execution of - aborted due to compilation errors.
204########
205# NAME Float constant overloading returning undef
206use overload;
207BEGIN { overload::constant float => sub {} }
2081.1
209EXPECT
bb4784f0 210Constant(1.1): Call to &{$^H{float}} did not return a defined value at - line 3, at end of line
b2e3d01a
FC
211Execution of - aborted due to compilation errors.
212########
213# NAME Binary constant overloading returning undef
214use overload;
215BEGIN { overload::constant binary => sub {} }
2160x1
217EXPECT
bb4784f0 218Constant(0x1): Call to &{$^H{binary}} did not return a defined value at - line 3, at end of line
b2e3d01a
FC
219Execution of - aborted due to compilation errors.
220########
221# NAME String constant overloading returning undef
222use overload;
223BEGIN { overload::constant q => sub {} }
224'1', "1$_", tr"a"", s""a"
225EXPECT
226Constant(q): Call to &{$^H{q}} did not return a defined value at - line 3, near "'1'"
227Constant(qq): Call to &{$^H{q}} did not return a defined value at - line 3, within string
228Constant(tr): Call to &{$^H{q}} did not return a defined value at - line 3, within string
229Constant(s): Call to &{$^H{q}} did not return a defined value at - line 3, within string
230Execution of - aborted due to compilation errors.
231########
232# NAME Regexp constant overloading returning undef
233use overload;
234BEGIN { overload::constant qr => sub {} }
235/a/, m'a'
236EXPECT
237Constant(qq): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
238Constant(q): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
239Execution of - aborted due to compilation errors.
240########
67c71cbb
FC
241# NAME Failed constant overloading should not cause a double free
242use overload;
243BEGIN { overload::constant q => sub {}; undef *^H }
244undef(1,2);
245undef(1,2);
246undef(1,2);
247undef(1,2);
248undef(1,2);
249undef(1,2);
250undef(1,2);
251undef(1,2);
252undef(1,2);
253"a"
254EXPECT
255Too many arguments for undef operator at - line 3, near "2)"
256Too many arguments for undef operator at - line 4, near "2)"
257Too many arguments for undef operator at - line 5, near "2)"
258Too many arguments for undef operator at - line 6, near "2)"
259Too many arguments for undef operator at - line 7, near "2)"
260Too many arguments for undef operator at - line 8, near "2)"
261Too many arguments for undef operator at - line 9, near "2)"
262Too many arguments for undef operator at - line 10, near "2)"
263Too many arguments for undef operator at - line 11, near "2)"
264Constant(q) unknown at - line 12, near ""a""
265- has too many errors.
266########
6f2d7fc9
FC
267# NAME Unterminated delimiter for here document
268<<"foo
269EXPECT
270Unterminated delimiter for here document at - line 1.
f3106bc8
LM
271########
272# NAME my (our $x) errors
273my (our $x);
274EXPECT
37808b00 275Can't redeclare "our" in "my" at - line 1, near "(our"
f3106bc8
LM
276Execution of - aborted due to compilation errors.
277########
278# NAME our (my $x) errors
279our (my $x);
280EXPECT
37808b00 281Can't redeclare "my" in "our" at - line 1, near "(my"
f3106bc8
LM
282Execution of - aborted due to compilation errors.
283########
284# NAME state (my $x) errors
285use feature 'state';
286state (my $x);
287EXPECT
37808b00 288Can't redeclare "my" in "state" at - line 2, near "(my"
f3106bc8
LM
289Execution of - aborted due to compilation errors.
290########
291# NAME our (state $x) errors
292use feature 'state';
293our (state $x);
294EXPECT
37808b00 295Can't redeclare "state" in "our" at - line 2, near "(state"
f3106bc8
LM
296Execution of - aborted due to compilation errors.
297########
298# NAME my (my $x) errors
299my (my $x, $y, $z);
300EXPECT
37808b00 301Can't redeclare "my" in "my" at - line 1, near "(my"
f3106bc8
LM
302Execution of - aborted due to compilation errors.
303########
304# NAME our (our $x) errors
305our ($x, our($y), $z);
306EXPECT
37808b00 307Can't redeclare "our" in "our" at - line 1, near ", our"
f3106bc8
LM
308Execution of - aborted due to compilation errors.
309########
310# NAME state (state $x) errors
311use feature 'state';
312state ($x, $y, state $z);
313EXPECT
37808b00 314Can't redeclare "state" in "state" at - line 2, near ", state"
f3106bc8 315Execution of - aborted due to compilation errors.
e6b2cf83
TC
316########
317# NAME BEGIN <> [perl #125341]
318BEGIN <>
319EXPECT
320Illegal declaration of subroutine BEGIN at - line 1.
e2733f9a
TC
321########
322# NAME multiple conflict markers
323<<<<<<< yours:sample.txt
324my $some_code;
325=======
326my $some_other_code;
327>>>>>>> theirs:sample.txt
328EXPECT
329Version control conflict marker at - line 1, near "<<<<<<<"
330Version control conflict marker at - line 3, near "======="
331Version control conflict marker at - line 5, near ">>>>>>>"
332Execution of - aborted due to compilation errors.
a3164817
FC
333########
334# NAME (Might be a runaway multi-line...) with Latin-1 delimiters in utf8
335BEGIN { binmode STDERR, ':utf8' }
336use utf8;
337
338« time
339EXPECT
340syntax error at - line 4, near "« time"
341 (Might be a runaway multi-line «« string starting on line 3)
342Execution of - aborted due to compilation errors.
343########
344# NAME (Might be a runaway multi-line...) with non-Latin-1 delimiters
345BEGIN { binmode STDERR, ':utf8' }
346use utf8;
347q ϡ
348ϡ time
349EXPECT
350syntax error at - line 4, near "ϡ time"
351 (Might be a runaway multi-line ϡϡ string starting on line 3)
352Execution of - aborted due to compilation errors.
59143e29
TC
353########
354# NAME tr/// handling of mis-formatted \o characters
355# may only fail with ASAN
356tr/\o-0//;
357EXPECT
358Missing braces on \o{} at - line 2, within string
359Execution of - aborted due to compilation errors.