1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
|
__END__
# NAME join,
join,
EXPECT
Not enough arguments for join or string at - line 1, near "join,"
Execution of - aborted due to compilation errors.
########
# NAME my $<special>
my $!;
EXPECT
Can't use global $! in "my" at - line 1, near "my $!"
Execution of - aborted due to compilation errors.
########
# NAME my $<non-ASCII> doesn't output garbage
# \xB6 is same character in all three EBCDIC pages and Latin1
use open ":std", ":utf8";
eval qq|my \$\xb6;|; # ¶ in Latin-1, and EBCDIC 1047, 037, POSIX-BC
print $@;
exit 1;
EXPECT
Can't use global $¶ in "my" at (eval 1) line 1, near "my $¶"
########
# NAME OP_HELEM fields
package Foo;
use fields qw(a b);
sub new {
my $class = shift;
return fields::new($class);
}
my Foo $f = Foo->new;
$f->{c} = 1;
EXPECT
No such class field "c" in variable $f of type Foo at - line 8.
########
# NAME "No such field" with block: ${$ref}{key}
%FIELDS; # empty hash so all keys are invalid
my main $r;
${$r}{key};
EXPECT
No such class field "key" in variable $r of type main at - line 3.
########
# NAME OP_HSLICE fields
package Foo;
use fields qw(a b);
sub new {
my $class = shift;
return fields::new($class);
}
my Foo $f = Foo->new;
@$f{"a", "c"} = ( 1, 2 );
EXPECT
No such class field "c" in variable $f of type Foo at - line 8.
########
# NAME Single OP_HSLICE field
%FIELDS; # vivify it, but leave it empty, so all fields are invalid
my main $f;
@$f{"a"};
EXPECT
No such class field "a" in variable $f of type main at - line 3.
########
# NAME OP_KVHSLICE fields
BEGIN { %FIELDS = qw(a 1 b 1); }
my main $f;
%$f{"a","c"};
EXPECT
No such class field "c" in variable $f of type main at - line 3.
########
# NAME Num-specific &= on @array
use feature 'bitwise';
@a &= 1;
EXPECT
Can't modify array dereference in numeric bitwise and (&) at - line 2, near "1;"
Execution of - aborted due to compilation errors.
########
# NAME Num-specific |= on @array
use feature 'bitwise';
@a |= 1;
EXPECT
Can't modify array dereference in numeric bitwise or (|) at - line 2, near "1;"
Execution of - aborted due to compilation errors.
########
# NAME Num-specific ^= on @array
use feature 'bitwise';
@a ^= 1;
EXPECT
Can't modify array dereference in numeric bitwise xor (^) at - line 2, near "1;"
Execution of - aborted due to compilation errors.
########
# NAME &.= on @array
use feature 'bitwise';
@a &.= 1;
EXPECT
Can't modify array dereference in string bitwise and (&.) at - line 2, near "1;"
Execution of - aborted due to compilation errors.
########
# NAME |.= on @array
use feature 'bitwise';
@a |.= 1;
EXPECT
Can't modify array dereference in string bitwise or (|.) at - line 2, near "1;"
Execution of - aborted due to compilation errors.
########
# NAME ^.= on @array
use feature 'bitwise';
@a ^.= 1;
EXPECT
Can't modify array dereference in string bitwise xor (^.) at - line 2, near "1;"
Execution of - aborted due to compilation errors.
########
# NAME substr %h in scalar assignment
substr(%h,0) = 3;
EXPECT
Can't modify hash dereference in substr at - line 1, near "3;"
Execution of - aborted due to compilation errors.
########
# NAME substr %h in list assignment
(substr %h,0) = 3;
EXPECT
Can't modify hash dereference in substr at - line 1, near "3;"
Execution of - aborted due to compilation errors.
########
# NAME vec %h in scalar assignment
vec(%h,1,1) = 3;
EXPECT
Can't modify hash dereference in vec at - line 1, near "3;"
Execution of - aborted due to compilation errors.
########
# NAME vec %h in list assignment
(vec %h,1,1) = 3;
EXPECT
Can't modify hash dereference in vec at - line 1, near "3;"
Execution of - aborted due to compilation errors.
########
# NAME Can't declare conditional
my($a?$b:$c)
EXPECT
Can't declare conditional expression in "my" at - line 1, at EOF
Execution of - aborted due to compilation errors.
########
# NAME Can't declare do block
my(do{})
EXPECT
Can't declare do block in "my" at - line 1, at EOF
Execution of - aborted due to compilation errors.
########
# NAME ($_, state $x) = ...
($_, CORE::state $x) = ();
EXPECT
Initialization of state variables in list currently forbidden at - line 1, near ");"
Execution of - aborted due to compilation errors.
########
# NAME my $y; ($y, state $x) = ...
my $y; ($y, CORE::state $x) = ();
EXPECT
Initialization of state variables in list currently forbidden at - line 1, near ");"
Execution of - aborted due to compilation errors.
########
# NAME delete BAD
delete $x;
EXPECT
delete argument is not a HASH or ARRAY element or slice at - line 1.
########
# NAME delete sort
use warnings;
delete sort 1; # used to warn about scalar context, too
EXPECT
delete argument is not a HASH or ARRAY element or slice at - line 2.
########
# NAME exists BAD
exists $x;
EXPECT
exists argument is not a HASH or ARRAY element or a subroutine at - line 1.
########
# NAME exists non-sub
exists &foo()
EXPECT
exists argument is not a subroutine name at - line 1.
########
# NAME push BAREWORD
push FRED;
EXPECT
Type of arg 1 to push must be array (not constant item) at - line 1, near "FRED;"
Execution of - aborted due to compilation errors.
########
# NAME pop BAREWORD
pop FRED;
EXPECT
Type of arg 1 to pop must be array (not constant item) at - line 1, near "FRED;"
Execution of - aborted due to compilation errors.
########
# NAME shift BAREWORD
shift FRED;
EXPECT
Type of arg 1 to shift must be array (not constant item) at - line 1, near "FRED;"
Execution of - aborted due to compilation errors.
########
# NAME unshift BAREWORD
unshift FRED;
EXPECT
Type of arg 1 to unshift must be array (not constant item) at - line 1, near "FRED;"
Execution of - aborted due to compilation errors.
########
# NAME keys BAREWORD
@a = keys FRED ;
EXPECT
Type of arg 1 to keys must be hash or array (not constant item) at - line 1, near "FRED ;"
Execution of - aborted due to compilation errors.
########
# NAME values BAREWORD
@a = values FRED ;
EXPECT
Type of arg 1 to values must be hash or array (not constant item) at - line 1, near "FRED ;"
Execution of - aborted due to compilation errors.
########
# NAME each BAREWORD
@a = each FRED ;
EXPECT
Type of arg 1 to each must be hash or array (not constant item) at - line 1, near "FRED ;"
Execution of - aborted due to compilation errors.
########
# NAME better messages for array-ops on non-arrays
push %a, 1;
pop %a;
shift %a;
unshift %a, 1;
push *a, 1;
pop *a;
shift *a;
unshift *a, 1;
EXPECT
Type of arg 1 to push must be array (not hash dereference) at - line 1, near "1;"
Type of arg 1 to pop must be array (not hash dereference) at - line 2, near "%a;"
Type of arg 1 to shift must be array (not hash dereference) at - line 3, near "%a;"
Type of arg 1 to unshift must be array (not hash dereference) at - line 4, near "1;"
Type of arg 1 to push must be array (not ref-to-glob cast) at - line 5, near "1;"
Type of arg 1 to pop must be array (not ref-to-glob cast) at - line 6, near "*a;"
Type of arg 1 to shift must be array (not ref-to-glob cast) at - line 7, near "*a;"
Type of arg 1 to unshift must be array (not ref-to-glob cast) at - line 8, near "1;"
Execution of - aborted due to compilation errors.
########
# NAME better messages for array-ops on non-arrays (part 2)
# to check PADHV without hitting the reported error limit
my %a;
push %a, 1;
pop %a;
shift %a;
unshift %a, 1;
EXPECT
Type of arg 1 to push must be array (not private hash) at - line 3, near "1;"
Type of arg 1 to pop must be array (not private hash) at - line 4, near "%a;"
Type of arg 1 to shift must be array (not private hash) at - line 5, near "%a;"
Type of arg 1 to unshift must be array (not private hash) at - line 6, near "1;"
Execution of - aborted due to compilation errors.
########
use feature 'defer';
no warnings 'experimental::defer';
defer { return "retval" }
EXPECT
Can't "return" out of a "defer" block at - line 3.
########
use feature 'defer';
no warnings 'experimental::defer';
defer { goto HERE }
HERE:
EXPECT
Can't "goto" out of a "defer" block at - line 3.
########
use feature 'defer';
no warnings 'experimental::defer';
my $subB = sub {};
defer { goto &$subB }
EXPECT
Can't "goto" out of a "defer" block at - line 4.
########
use feature 'defer';
no warnings 'experimental::defer';
LOOP: while(1) {
defer { last LOOP }
}
EXPECT
Can't "last" out of a "defer" block at - line 4.
########
use feature 'try';
no warnings 'experimental::try';
try {} catch ($e) {} finally { return "123" }
EXPECT
Can't "return" out of a "finally" block at - line 3.
########
use feature 'try';
no warnings 'experimental::try';
try {} catch ($e) {} finally { goto HERE; }
HERE:
EXPECT
Can't "goto" out of a "finally" block at - line 3.
########
use feature 'try';
no warnings 'experimental::try';
LOOP: {
try {} catch ($e) {} finally { last LOOP; }
}
EXPECT
Can't "last" out of a "finally" block at - line 4.
########
# NAME return HANDLE LIST isn't valid [github #21716]
sub xx {
return sum map { $_+1} 1 .. 5;
}
EXPECT
Missing comma after first argument to return at - line 2, near "5;"
Execution of - aborted due to compilation errors.
########
# subsequent use VERSION to 5.39
use v5.20;
use v5.39;
EXPECT
use VERSION of 5.39 or above is not permitted while another use VERSION is in scope at - line 3.
########
# subsequent use VERSION from 5.39
use v5.39;
use v5.20;
EXPECT
use VERSION is not permitted while another use VERSION of 5.39 or above is in scope at - line 3.
########
# use VERSION across the 5.11 boundary
use 5.012;
use 5.010;
EXPECT
Downgrading a use VERSION declaration to below v5.11 is not permitted at - line 3.
########
# any with deferred LIST expression
use feature 'keyword_any';
no warnings 'experimental::keyword_any';
any length, qw( a b c )
EXPECT
syntax error at - line 4, near "any length"
Execution of - aborted due to compilation errors.
########
# all with deferred LIST expression
use feature 'keyword_all';
no warnings 'experimental::keyword_all';
all length, qw( a b c )
EXPECT
syntax error at - line 4, near "all length"
Execution of - aborted due to compilation errors.
|