This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
op.c: Factor out two identical yyerror calls
[perl5.git] / t / lib / croak / op
CommitLineData
7a44ba35 1__END__
b14845b4
FC
2# NAME my $<special>
3my $!;
4EXPECT
5Can't use global $! in "my" at - line 1, near "my $!"
6Execution of - aborted due to compilation errors.
7########
7a44ba35
TC
8# NAME OP_HELEM fields
9package Foo;
10use fields qw(a b);
11sub new {
12 my $class = shift;
13 return fields::new($class);
14}
15my Foo $f = Foo->new;
16$f->{c} = 1;
17EXPECT
18No such class field "c" in variable $f of type Foo at - line 8.
19########
e6307ed0
FC
20# NAME "No such field" with block: ${$ref}{key}
21%FIELDS; # empty hash so all keys are invalid
22my main $r;
23${$r}{key};
24EXPECT
25No such class field "key" in variable $r of type main at - line 3.
26########
7a44ba35
TC
27# NAME OP_HSLICE fields
28package Foo;
29use fields qw(a b);
30sub new {
31 my $class = shift;
32 return fields::new($class);
33}
34my Foo $f = Foo->new;
35@$f{"a", "c"} = ( 1, 2 );
36EXPECT
37No such class field "c" in variable $f of type Foo at - line 8.
38########
0e706dd4
FC
39# NAME Single OP_HSLICE field
40%FIELDS; # vivify it, but leave it empty, so all fields are invalid
41my main $f;
42@$f{"a"};
43EXPECT
44No such class field "a" in variable $f of type main at - line 3.
45########
c5f75dba
FC
46# NAME OP_KVHSLICE fields
47BEGIN { %FIELDS = qw(a 1 b 1); }
48my main $f;
49%$f{"a","c"};
50EXPECT
51No such class field "c" in variable $f of type main at - line 3.
52########
7a44ba35
TC
53# NAME delete BAD
54delete $x;
55EXPECT
56delete argument is not a HASH or ARRAY element or slice at - line 1.
57########
2186f873
FC
58# NAME delete sort
59use warnings;
60delete sort; # used to warn about scalar context, too
61EXPECT
62delete argument is not a HASH or ARRAY element or slice at - line 2.
63########
7a44ba35
TC
64# NAME exists BAD
65exists $x;
66EXPECT
67exists argument is not a HASH or ARRAY element or a subroutine at - line 1.
68########
69# NAME exists non-sub
70exists &foo()
71EXPECT
72exists argument is not a subroutine name at - line 1.