This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
initialisation of simple aggregate state variables
[perl5.git] / t / lib / croak / op
CommitLineData
7a44ba35 1__END__
a4545448
FC
2# NAME join,
3join,
4EXPECT
5Not enough arguments for join or string at - line 1, near "join,"
6Execution of - aborted due to compilation errors.
7########
b14845b4
FC
8# NAME my $<special>
9my $!;
10EXPECT
11Can't use global $! in "my" at - line 1, near "my $!"
12Execution of - aborted due to compilation errors.
13########
ec7e59fb
KW
14# NAME my $<non-ASCII> doesn't output garbage
15# \xB6 is same character in all three EBCDIC pages and Latin1
f6a1dc93 16use open ":std", ":utf8";
ec7e59fb 17eval qq|my \$\xb6;|; # ¶ in Latin-1, and EBCDIC 1047, 037, POSIX-BC
f6a1dc93
FC
18print $@;
19exit 1;
20EXPECT
ec7e59fb 21Can't use global $¶ in "my" at (eval 1) line 1, near "my $¶"
f6a1dc93 22########
7a44ba35
TC
23# NAME OP_HELEM fields
24package Foo;
25use fields qw(a b);
26sub new {
27 my $class = shift;
28 return fields::new($class);
29}
30my Foo $f = Foo->new;
31$f->{c} = 1;
32EXPECT
33No such class field "c" in variable $f of type Foo at - line 8.
34########
e6307ed0
FC
35# NAME "No such field" with block: ${$ref}{key}
36%FIELDS; # empty hash so all keys are invalid
37my main $r;
38${$r}{key};
39EXPECT
40No such class field "key" in variable $r of type main at - line 3.
41########
7a44ba35
TC
42# NAME OP_HSLICE fields
43package Foo;
44use fields qw(a b);
45sub new {
46 my $class = shift;
47 return fields::new($class);
48}
49my Foo $f = Foo->new;
50@$f{"a", "c"} = ( 1, 2 );
51EXPECT
52No such class field "c" in variable $f of type Foo at - line 8.
53########
0e706dd4
FC
54# NAME Single OP_HSLICE field
55%FIELDS; # vivify it, but leave it empty, so all fields are invalid
56my main $f;
57@$f{"a"};
58EXPECT
59No such class field "a" in variable $f of type main at - line 3.
60########
c5f75dba
FC
61# NAME OP_KVHSLICE fields
62BEGIN { %FIELDS = qw(a 1 b 1); }
63my main $f;
64%$f{"a","c"};
65EXPECT
66No such class field "c" in variable $f of type main at - line 3.
67########
76734a32
FC
68# NAME Num-specific &= on @array
69use feature 'bitwise';
70@a &= 1;
71EXPECT
72The bitwise feature is experimental at - line 2.
73Can't modify array dereference in numeric bitwise and (&) at - line 2, near "1;"
74Execution of - aborted due to compilation errors.
75########
76# NAME Num-specific |= on @array
77use feature 'bitwise';
78@a |= 1;
79EXPECT
80The bitwise feature is experimental at - line 2.
81Can't modify array dereference in numeric bitwise or (|) at - line 2, near "1;"
82Execution of - aborted due to compilation errors.
83########
84# NAME Num-specific ^= on @array
85use feature 'bitwise';
86@a ^= 1;
87EXPECT
88The bitwise feature is experimental at - line 2.
89Can't modify array dereference in numeric bitwise xor (^) at - line 2, near "1;"
90Execution of - aborted due to compilation errors.
91########
92# NAME &.= on @array
93use feature 'bitwise';
94@a &.= 1;
95EXPECT
96The bitwise feature is experimental at - line 2.
97Can't modify array dereference in string bitwise and (&.) at - line 2, near "1;"
98Execution of - aborted due to compilation errors.
99########
100# NAME |.= on @array
101use feature 'bitwise';
102@a |.= 1;
103EXPECT
104The bitwise feature is experimental at - line 2.
105Can't modify array dereference in string bitwise or (|.) at - line 2, near "1;"
106Execution of - aborted due to compilation errors.
107########
108# NAME ^.= on @array
109use feature 'bitwise';
110@a ^.= 1;
111EXPECT
112The bitwise feature is experimental at - line 2.
113Can't modify array dereference in string bitwise xor (^.) at - line 2, near "1;"
114Execution of - aborted due to compilation errors.
115########
79409ac8
FC
116# NAME substr %h in scalar assignment
117substr(%h,0) = 3;
118EXPECT
119Can't modify hash dereference in substr at - line 1, near "3;"
120Execution of - aborted due to compilation errors.
121########
122# NAME substr %h in list assignment
123(substr %h,0) = 3;
124EXPECT
125Can't modify hash dereference in substr at - line 1, near "3;"
126Execution of - aborted due to compilation errors.
127########
128# NAME vec %h in scalar assignment
129vec(%h,1,1) = 3;
130EXPECT
131Can't modify hash dereference in vec at - line 1, near "3;"
132Execution of - aborted due to compilation errors.
133########
134# NAME vec %h in list assignment
135(vec %h,1,1) = 3;
136EXPECT
137Can't modify hash dereference in vec at - line 1, near "3;"
138Execution of - aborted due to compilation errors.
139########
4748e002
FC
140# NAME Can't declare conditional
141my($a?$b:$c)
142EXPECT
143Can't declare conditional expression in "my" at - line 1, at EOF
144Execution of - aborted due to compilation errors.
145########
146# NAME Can't declare do block
147my(do{})
148EXPECT
149Can't declare do block in "my" at - line 1, at EOF
150Execution of - aborted due to compilation errors.
151########
f0614d30
FC
152# NAME ($_, state $x) = ...
153($_, CORE::state $x) = ();
154EXPECT
f99042c8 155Initialization of state variables in list currently forbidden at - line 1, near ");"
f0614d30
FC
156Execution of - aborted due to compilation errors.
157########
158# NAME my $y; ($y, state $x) = ...
159my $y; ($y, CORE::state $x) = ();
160EXPECT
f99042c8 161Initialization of state variables in list currently forbidden at - line 1, near ");"
f0614d30
FC
162Execution of - aborted due to compilation errors.
163########
7a44ba35
TC
164# NAME delete BAD
165delete $x;
166EXPECT
167delete argument is not a HASH or ARRAY element or slice at - line 1.
168########
2186f873
FC
169# NAME delete sort
170use warnings;
171delete sort; # used to warn about scalar context, too
172EXPECT
173delete argument is not a HASH or ARRAY element or slice at - line 2.
174########
7a44ba35
TC
175# NAME exists BAD
176exists $x;
177EXPECT
178exists argument is not a HASH or ARRAY element or a subroutine at - line 1.
179########
180# NAME exists non-sub
181exists &foo()
182EXPECT
183exists argument is not a subroutine name at - line 1.
b5adc3e5
DIM
184########
185# NAME push BAREWORD
b5adc3e5
DIM
186push FRED;
187EXPECT
26230909 188Type of arg 1 to push must be array (not constant item) at - line 1, near "FRED;"
b5adc3e5
DIM
189Execution of - aborted due to compilation errors.
190########
191# NAME pop BAREWORD
b5adc3e5
DIM
192pop FRED;
193EXPECT
26230909 194Type of arg 1 to pop must be array (not constant item) at - line 1, near "FRED;"
b5adc3e5
DIM
195Execution of - aborted due to compilation errors.
196########
197# NAME shift BAREWORD
b5adc3e5
DIM
198shift FRED;
199EXPECT
26230909 200Type of arg 1 to shift must be array (not constant item) at - line 1, near "FRED;"
b5adc3e5
DIM
201Execution of - aborted due to compilation errors.
202########
203# NAME unshift BAREWORD
b5adc3e5
DIM
204unshift FRED;
205EXPECT
26230909 206Type of arg 1 to unshift must be array (not constant item) at - line 1, near "FRED;"
b5adc3e5
DIM
207Execution of - aborted due to compilation errors.
208########
209# NAME keys BAREWORD
210@a = keys FRED ;
211EXPECT
69e7f50e 212Type of arg 1 to keys must be hash or array (not constant item) at - line 1, near "FRED ;"
b5adc3e5
DIM
213Execution of - aborted due to compilation errors.
214########
215# NAME values BAREWORD
216@a = values FRED ;
217EXPECT
69e7f50e 218Type of arg 1 to values must be hash or array (not constant item) at - line 1, near "FRED ;"
b5adc3e5
DIM
219Execution of - aborted due to compilation errors.
220########
221# NAME each BAREWORD
222@a = each FRED ;
223EXPECT
69e7f50e 224Type of arg 1 to each must be hash or array (not constant item) at - line 1, near "FRED ;"
b5adc3e5 225Execution of - aborted due to compilation errors.