1__END__
2# NAME foo found where operator expected
3myfunc 1,2,3
4EXPECT
5Number found where operator expected (Do you need to predeclare "myfunc"?) at - line 1, near "myfunc 1"
6syntax error at - line 1, near "myfunc 1"
7Execution of - aborted due to compilation errors.
8########
9# NAME foo found where operator expected (after strict error, w/fatal warnings)
10use warnings FATAL => 'all';
11use strict;
12$foo;
13myfunc 1,2,3
14EXPECT
15Global symbol "$foo" requires explicit package name (did you forget to declare "my $foo"?) at - line 3.
16Number found where operator expected (Do you need to predeclare "myfunc"?) at - line 4, near "myfunc 1"
17syntax error at - line 4, near "myfunc 1"
18Execution of - aborted due to compilation errors.
19########
20# NAME (Missing operator before "${"?) [perl #123737]
210${
22EXPECT
23Scalar found where operator expected (Missing operator before "${"?) at - line 1, near "0${"
24syntax error at - line 1, near "0$"
25Execution of - aborted due to compilation errors.
26########
27# NAME (Missing operator before "$#{"?) [perl #123737]
280$#{
29EXPECT
30Array length found where operator expected (Missing operator before "$#{"?) at - line 1, near "0$#{"
31syntax error at - line 1, near "0$#"
32Execution of - aborted due to compilation errors.
33########
34# NAME (Missing operator before "@foo") [perl #123737]
350@foo
36EXPECT
37Array found where operator expected (Missing operator before "@foo"?) at - line 1, near "0@foo"
38syntax error at - line 1, near "0@foo
39"
40Execution of - aborted due to compilation errors.
41########
42# NAME (Missing operator before "@{") [perl #123737]
430@{
44EXPECT
45Array found where operator expected (Missing operator before "@{"?) at - line 1, near "0@{"
46syntax error at - line 1, near "0@"
47Execution of - aborted due to compilation errors.
48########
49# NAME Unterminated here-doc in string eval
50eval "<<foo"; die $@
51EXPECT
52Can't find string terminator "foo" anywhere before EOF at (eval 1) line 1.
53########
54# NAME Unterminated here-doc in s/// string eval
55eval "s//<<foo/e"; die $@
56EXPECT
57Can't find string terminator "foo" anywhere before EOF at (eval 1) line 1.
58########
59# NAME Unterminated here-doc in string
60"${<<foo"; # Used to give ���Attempt to free blah blah blah���
61EXPECT
62Can't find string terminator "foo" anywhere before EOF at - line 1.
63########
64# NAME Unterminated here-doc with non-Latin-1 terminator
65BEGIN { binmode STDERR, ":utf8" }
66use utf8;
67<<������
68EXPECT
69Can't find string terminator "������" anywhere before EOF at - line 3.
70########
71# NAME Unterminated qw//
72qw/
73EXPECT
74Can't find string terminator "/" anywhere before EOF at - line 1.
75########
76# NAME Unterminated q//
77qw/
78EXPECT
79Can't find string terminator "/" anywhere before EOF at - line 1.
80########
81# NAME Unterminated ''
82'
83EXPECT
84Can't find string terminator "'" anywhere before EOF at - line 1.
85########
86# NAME Unterminated ""
87"
88EXPECT
89Can't find string terminator '"' anywhere before EOF at - line 1.
90########
91# NAME Unterminated q// with non-ASCII delimiter, under utf8
92BEGIN { binmode STDERR, ":utf8" }
93use utf8;
94no warnings 'deprecated';
95q��
96EXPECT
97Can't find string terminator "��" anywhere before EOF at - line 4.
98########
99# NAME Unterminated q// with non-Latin-1 delimiter
100BEGIN { binmode STDERR, ":utf8" }
101use utf8;
102q ���
103EXPECT
104Can't find string terminator "���" anywhere before EOF at - line 3.
105########
106# NAME extra paired delimiters Latin1 range in UTF-8
107BEGIN { binmode STDERR, ":utf8" }
108use utf8;
109use feature 'extra_paired_delimiters';
110no warnings 'experimental::extra_paired_delimiters';
111my $good = q��this string has a mirrored terminator��;
112my $bad = q��this string needs to have a mirrored terminator��;
113EXPECT
114Can't find string terminator "��" anywhere before EOF at - line 6.
115########
116# NAME reversed extra paired delimiters Latin1 range in UTF-8
117BEGIN { binmode STDERR, ":utf8" }
118use utf8;
119use feature 'extra_paired_delimiters';
120no warnings 'experimental::extra_paired_delimiters';
121my $good = q��this string has a mirrored terminator��;
122my $bad = q��this string needs to have a mirrored terminator��;
123EXPECT
124Can't find string terminator "��" anywhere before EOF at - line 6.
125########
126# NAME paired non-ASCII Latin1 delimiters need feature enabled, in UTF-8
127BEGIN { binmode STDERR, ":utf8" }
128use utf8;
129my $good = q��this string works as before without the feature enabled��;
130no warnings 'deprecated';
131my $bad = q��this string has a mirrored terminator��;
132EXPECT
133Use of '��' is deprecated as a string delimiter at - line 3.
134Can't find string terminator "��" anywhere before EOF at - line 5.
135########
136# NAME paired above Latin1 delimiters need feature enabled
137BEGIN { binmode STDERR, ":utf8" }
138use utf8;
139my $bad = q���this string has a mirrored terminator���;
140EXPECT
141Use of '���' is deprecated as a string delimiter at - line 3.
142Can't find string terminator "���" anywhere before EOF at - line 3.
143########
144# NAME /\N{/
145/\N{/
146EXPECT
147Missing right brace on \N{} or unescaped left brace after \N at - line 1, within pattern
148Execution of - aborted due to compilation errors.
149########
150# NAME map{for our *a...
151map{for our *a (1..10) {$_.=$x}}
152EXPECT
153Missing $ on loop variable at - line 1.
154########
155# NAME Missing name in "my sub"
156use feature 'lexical_subs'; my sub;
157EXPECT
158Missing name in "my sub" at - line 1.
159########
160# NAME Missing name in "our sub"
161use feature 'lexical_subs'; our sub;
162EXPECT
163Missing name in "our sub" at - line 1.
164########
165# NAME Missing name in "state sub"
166use 5.01;
167state sub;
168EXPECT
169Missing name in "state sub" at - line 2.
170########
171# NAME our sub pack::foo
172our sub foo::bar;
173EXPECT
174No package name allowed for subroutine &foo::bar in "our" at - line 1, near "our sub foo::bar"
175Execution of - aborted due to compilation errors.
176########
177# NAME my sub pack::foo
178use feature 'lexical_subs', 'state';
179my sub foo::bar;
180state sub foo::bear;
181EXPECT
182"my" subroutine &foo::bar can't be in a package at - line 2, near "my sub foo::bar"
183"state" subroutine &foo::bear can't be in a package at - line 3, near "state sub foo::bear"
184Execution of - aborted due to compilation errors.
185########
186# NAME Integer constant overloading returning undef
187use overload;
188BEGIN { overload::constant integer => sub {}; undef *^H }
1891
190EXPECT
191Constant(1) unknown at - line 3, at end of line
192Execution of - aborted due to compilation errors.
193########
194# NAME Float constant overloading returning undef
195use overload;
196BEGIN { overload::constant float => sub {}; undef *^H }
1971.1
198EXPECT
199Constant(1.1) unknown at - line 3, at end of line
200Execution of - aborted due to compilation errors.
201########
202# NAME Binary constant overloading returning undef
203use overload;
204BEGIN { overload::constant binary => sub {}; undef *^H }
2050x1
206EXPECT
207Constant(0x1) unknown at - line 3, at end of line
208Execution of - aborted due to compilation errors.
209########
210# NAME String constant overloading returning undef
211use overload;
212BEGIN { overload::constant q => sub {}; undef *^H }
213'1', "1$_", tr"a"", s""a"
214EXPECT
215Constant(q) unknown at - line 3, near "'1'"
216Constant(qq) unknown at - line 3, within string
217Constant(tr) unknown at - line 3, within string
218Constant(s) unknown at - line 3, within string
219Execution of - aborted due to compilation errors.
220########
221# NAME Regexp constant overloading when *^H is undefined
222use overload;
223BEGIN { overload::constant qr => sub {}; undef *^H }
224/a/
225EXPECT
226Constant(qq) unknown at - line 3, within pattern
227Execution of - aborted due to compilation errors.
228########
229# NAME Regexp constant overloading when *^H is undefined
230use overload;
231BEGIN { overload::constant qr => sub {}; undef *^H }
232m'a'
233EXPECT
234Constant(q) unknown at - line 3, within pattern
235Execution of - aborted due to compilation errors.
236########
237# NAME \N{...} when charnames fails to load but without an error
238# SKIP ? exists $ENV{PERL_UNICODE} ? "Unreliable under some PERL_UNICODE settings" : 0
239BEGIN { ++$_ for @INC{"charnames.pm","_charnames.pm"} }
240"\N{a}"
241EXPECT
242Constant(\N{a}) unknown at - line 2, within string
243Execution of - aborted due to compilation errors.
244########
245# NAME Integer constant overloading returning undef
246use overload;
247BEGIN { overload::constant integer => sub {} }
2481
249EXPECT
250Constant(1): Call to &{$^H{integer}} did not return a defined value at - line 3, at end of line
251Execution of - aborted due to compilation errors.
252########
253# NAME Float constant overloading returning undef
254use overload;
255BEGIN { overload::constant float => sub {} }
2561.1
257EXPECT
258Constant(1.1): Call to &{$^H{float}} did not return a defined value at - line 3, at end of line
259Execution of - aborted due to compilation errors.
260########
261# NAME Binary constant overloading returning undef
262use overload;
263BEGIN { overload::constant binary => sub {} }
2640x1
265EXPECT
266Constant(0x1): Call to &{$^H{binary}} did not return a defined value at - line 3, at end of line
267Execution of - aborted due to compilation errors.
268########
269# NAME String constant overloading returning undef
270use overload;
271BEGIN { overload::constant q => sub {} }
272'1', "1$_", tr"a"", s""a"
273EXPECT
274Constant(q): Call to &{$^H{q}} did not return a defined value at - line 3, near "'1'"
275Constant(qq): Call to &{$^H{q}} did not return a defined value at - line 3, within string
276Constant(tr): Call to &{$^H{q}} did not return a defined value at - line 3, within string
277Constant(s): Call to &{$^H{q}} did not return a defined value at - line 3, within string
278Execution of - aborted due to compilation errors.
279########
280# NAME Regexp constant overloading returning undef
281use overload;
282BEGIN { overload::constant qr => sub {} }
283/a/
284EXPECT
285Constant(qq): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
286Execution of - aborted due to compilation errors.
287########
288# NAME Regexp constant overloading returning undef
289use overload;
290BEGIN { overload::constant qr => sub {} }
291m'a'
292EXPECT
293Constant(q): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
294Execution of - aborted due to compilation errors.
295########
296# NAME Failed constant overloading should not cause a double free
297use overload;
298BEGIN { overload::constant q => sub {}; undef *^H }
299undef(1,2);
300undef(1,2);
301undef(1,2);
302undef(1,2);
303undef(1,2);
304undef(1,2);
305undef(1,2);
306undef(1,2);
307undef(1,2);
308"a"
309EXPECT
310Too many arguments for undef operator at - line 3, near "2)"
311Too many arguments for undef operator at - line 4, near "2)"
312Too many arguments for undef operator at - line 5, near "2)"
313Too many arguments for undef operator at - line 6, near "2)"
314Too many arguments for undef operator at - line 7, near "2)"
315Too many arguments for undef operator at - line 8, near "2)"
316Too many arguments for undef operator at - line 9, near "2)"
317Too many arguments for undef operator at - line 10, near "2)"
318Too many arguments for undef operator at - line 11, near "2)"
319Constant(q) unknown at - line 12, near ""a""
320- has too many errors.
321########
322# NAME Bad name after ' (with other helpful messages)
323sub has{}
324has erdef => (
325    isa => 'Int',
326    is => 'ro,
327    default => sub { 1 }
328);
329
330has cxxc => (
331    isa => 'Int',
332    is => 'ro',
333    default => sub { 1 }
334);
335EXPECT
336Bareword found where operator expected (Do you need to predeclare "isa"?) at - line 9, near "isa => 'Int"
337  (Might be a runaway multi-line '' string starting on line 4)
338Bad name after Int' at - line 9.
339########
340# NAME Bad name after :: (with other helpful messages)
341sub has{}
342has erdef => (
343    isa => 'Int',
344    is => "ro,
345    default => sub { 1 }
346);
347
348has cxxc => (
349    isa => "Foo::$subpackage",
350    is => 'ro',
351    default => sub { 1 }
352);
353EXPECT
354Bareword found where operator expected (Do you need to predeclare "isa"?) at - line 9, near "isa => "Foo"
355  (Might be a runaway multi-line "" string starting on line 4)
356Bad name after Foo:: at - line 9.
357########
358# NAME Unterminated delimiter for here document
359<<"foo
360EXPECT
361Unterminated delimiter for here document at - line 1.
362########
363# NAME my (our $x) errors
364my (our $x);
365EXPECT
366Can't redeclare "our" in "my" at - line 1, near "(our"
367Execution of - aborted due to compilation errors.
368########
369# NAME our (my $x) errors
370our (my $x);
371EXPECT
372Can't redeclare "my" in "our" at - line 1, near "(my"
373Execution of - aborted due to compilation errors.
374########
375# NAME state (my $x) errors
376use feature 'state';
377state (my $x);
378EXPECT
379Can't redeclare "my" in "state" at - line 2, near "(my"
380Execution of - aborted due to compilation errors.
381########
382# NAME our (state $x) errors
383use feature 'state';
384our (state $x);
385EXPECT
386Can't redeclare "state" in "our" at - line 2, near "(state"
387Execution of - aborted due to compilation errors.
388########
389# NAME my (my $x) errors
390my (my $x, $y, $z);
391EXPECT
392Can't redeclare "my" in "my" at - line 1, near "(my"
393Execution of - aborted due to compilation errors.
394########
395# NAME our (our $x) errors
396our ($x, our($y), $z);
397EXPECT
398Can't redeclare "our" in "our" at - line 1, near ", our"
399Execution of - aborted due to compilation errors.
400########
401# NAME state (state $x) errors
402use feature 'state';
403state ($x, $y, state $z);
404EXPECT
405Can't redeclare "state" in "state" at - line 2, near ", state"
406Execution of - aborted due to compilation errors.
407########
408# NAME BEGIN <> [perl #125341]
409BEGIN <>
410EXPECT
411Illegal declaration of subroutine BEGIN at - line 1.
412########
413# NAME multiple conflict markers.
414# NOTE the <CONFLICT< style text is auto-replaced in test.pl run_multiple_progs
415<CONFLICT< yours:sample.txt
416my $some_code;
417=CONFLICT=
418my $some_other_code;
419>CONFLICT> theirs:sample.txt
420EXPECT
421Version control conflict marker at - line 1, near "<CONFLICT<"
422Version control conflict marker at - line 3, near "=CONFLICT="
423Version control conflict marker at - line 5, near ">CONFLICT>"
424Execution of - aborted due to compilation errors.
425########
426# NAME (Might be a runaway multi-line...) with Latin-1 delimiters in utf8
427BEGIN { binmode STDERR, ':utf8' }
428use utf8;
429no warnings 'deprecated';
430q��
431�� time
432EXPECT
433syntax error at - line 5, near "�� time"
434  (Might be a runaway multi-line ���� string starting on line 4)
435Execution of - aborted due to compilation errors.
436########
437# NAME (Might be a runaway multi-line...) with non-Latin-1 delimiters
438BEGIN { binmode STDERR, ':utf8' }
439use utf8;
440q ��
441�� time
442EXPECT
443syntax error at - line 4, near "�� time"
444  (Might be a runaway multi-line ���� string starting on line 3)
445Execution of - aborted due to compilation errors.
446########
447# NAME tr/// handling of mis-formatted \o characters
448# may only fail with ASAN
449tr/\o-0//;
450EXPECT
451Missing braces on \o{} at - line 2, within string
452Execution of - aborted due to compilation errors.
453########
454# NAME bare <<
455$a = <<;
456
457EXPECT
458Use of bare << to mean <<"" is forbidden at - line 1.
459########
460# NAME bare <<~
461$a = <<~;
462EXPECT
463Use of bare << to mean <<"" is forbidden at - line 1.
464########
465# NAME bare <<~
466$a = <<~ ;
467
468EXPECT
469Use of bare << to mean <<"" is forbidden at - line 1.
470########
471# NAME incomplete floating point decimal exponent (#131725)
4721e--5
473EXPECT
474Bareword found where operator expected (Missing operator before "e"?) at - line 1, near "1e"
475syntax error at - line 1, near "1e"
476Execution of - aborted due to compilation errors.
477########
478# NAME signature with non-"=" assignop #131777
479use feature 'signatures';
480sub foo ($a += 1)
481EXPECT
482Illegal operator following parameter in a subroutine signature at - line 2, near "($a += 1"
483syntax error at - line 2, near "($a += 1"
484Execution of - aborted due to compilation errors.
485########
486# NAME tr/// range with empty \N{} at the start
487tr//\N{}-0/;
488EXPECT
489Unknown charname '' at - line 1, within string
490Execution of - aborted due to compilation errors.
491########
492# NAME octal fp with non-octal digits after the decimal point
49301.1234567p0;
49407.8p0;
495EXPECT
496Bareword found where operator expected (Missing operator before "p0"?) at - line 2, near "8p0"
497syntax error at - line 2, near "8p0"
498Execution of - aborted due to compilation errors.
499########
500# NAME binary fp with non-binary digits after the decimal point
5010b1.10p0;
5020b1.2p0;
503EXPECT
504Bareword found where operator expected (Missing operator before "p0"?) at - line 2, near "2p0"
505syntax error at - line 2, near "2p0"
506Execution of - aborted due to compilation errors.
507########
508# NAME dump() must be written as CORE::dump() as of Perl 5.30
509BEGIN { $^C = 1; }
510dump;
511CORE::dump;
512EXPECT
513dump() must be written as CORE::dump() as of Perl 5.30 at - line 2.
514########
515# NAME check Prototype not terminated includes line number (133524)
516sub t1 {}
517sub t2 (}
518EXPECT
519Prototype not terminated at - line 2.
520########
521# NAME [perl #132158] format with syntax errors
522format=
523@
524=h
525=cut
526EXPECT
527syntax error at - line 4, next token ???
528Execution of - aborted due to compilation errors.
529########
530# NAME [perl #134125] [gh #17010] incomplete hex number
5310x x 2;
5320xx 2;
5330x_;
5340b;
535EXPECT
536No digits found for hexadecimal literal at - line 1, near "0x "
537No digits found for hexadecimal literal at - line 2, near "0xx"
538No digits found for hexadecimal literal at - line 3, near "0x_;"
539No digits found for binary literal at - line 4, near "0b;"
540Execution of - aborted due to compilation errors.
541########
542# NAME [perl #130585] close paren in subparse
543qr!@{s{0})(?{!;
544EXPECT
545syntax error at - line 1, near "})"
546Execution of - aborted due to compilation errors.
547########
548# NAME [perl #130585] close paren in subparse - a few more tests
549my ($x, %y, @z);
550qq!$x\U $z[0] $y{a}\E $z[1]!;
551qq!$x\U@{s{0})(?{!;
552EXPECT
553syntax error at - line 3, near ")("
554Execution of - aborted due to compilation errors.
555########
556# NAME [perl #134310] don't confuse S_no_op() with PL_bufptr after s
5570 0x@
558EXPECT
559Number found where operator expected (Missing operator before "0x"?) at - line 1, near "0 0x"
560No digits found for hexadecimal literal at - line 1, near "0 0x@"
561syntax error at - line 1, near "0 0x"
562Execution of - aborted due to compilation errors.
563########
564# NAME Forbid illegal \x{} code points
565use Config;
566if ($Config{uvsize} < 8) {
567    my $a = "\x{8000_0000}";
568}
569else {
570    my $a = "\x{8000_0000_0000_0000}";
571}
572EXPECT
573OPTIONS regex
574Use of code point 0x80000000(00000000)? is not allowed; the permissible max is 0x7FFFFFFF(FFFFFFFF)? at - line \d+.
575########
576# NAME Forbid illegal \o{} code points
577use Config;
578if ($Config{uvsize} < 8) {
579    my $b = "\o{20_000_000_000}";
580}
581else {
582    my $b = "\o{1_000_000_000_000_000_000_000}";
583}
584EXPECT
585OPTIONS regex
586Use of code point 0x80000000(00000000)? is not allowed; the permissible max is 0x7FFFFFFF(FFFFFFFF)? at - line \d+.
587########
588# NAME gh-17645: conflict marker detection should not read out of bounds
589m/$0[
590==0/
591EXPECT
592syntax error at - line 2, near "[
593=="
594  (Might be a runaway multi-line // string starting on line 1)
595Execution of - aborted due to compilation errors.
596