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