1__END__ 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######## 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######## 14# NAME my $<non-ASCII> doesn't output garbage 15# \xB6 is same character in all three EBCDIC pages and Latin1 16use open ":std", ":utf8"; 17eval qq|my \$\xb6;|; # �� in Latin-1, and EBCDIC 1047, 037, POSIX-BC 18print $@; 19exit 1; 20EXPECT 21Can't use global $�� in "my" at (eval 1) line 1, near "my $��" 22######## 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######## 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######## 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######## 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######## 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######## 68# NAME Num-specific &= on @array 69use feature 'bitwise'; 70@a &= 1; 71EXPECT 72Can't modify array dereference in numeric bitwise and (&) at - line 2, near "1;" 73Execution of - aborted due to compilation errors. 74######## 75# NAME Num-specific |= on @array 76use feature 'bitwise'; 77@a |= 1; 78EXPECT 79Can't modify array dereference in numeric bitwise or (|) at - line 2, near "1;" 80Execution of - aborted due to compilation errors. 81######## 82# NAME Num-specific ^= on @array 83use feature 'bitwise'; 84@a ^= 1; 85EXPECT 86Can't modify array dereference in numeric bitwise xor (^) at - line 2, near "1;" 87Execution of - aborted due to compilation errors. 88######## 89# NAME &.= on @array 90use feature 'bitwise'; 91@a &.= 1; 92EXPECT 93Can't modify array dereference in string bitwise and (&.) at - line 2, near "1;" 94Execution of - aborted due to compilation errors. 95######## 96# NAME |.= on @array 97use feature 'bitwise'; 98@a |.= 1; 99EXPECT 100Can't modify array dereference in string bitwise or (|.) at - line 2, near "1;" 101Execution of - aborted due to compilation errors. 102######## 103# NAME ^.= on @array 104use feature 'bitwise'; 105@a ^.= 1; 106EXPECT 107Can't modify array dereference in string bitwise xor (^.) at - line 2, near "1;" 108Execution of - aborted due to compilation errors. 109######## 110# NAME substr %h in scalar assignment 111substr(%h,0) = 3; 112EXPECT 113Can't modify hash dereference in substr at - line 1, near "3;" 114Execution of - aborted due to compilation errors. 115######## 116# NAME substr %h in list assignment 117(substr %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 vec %h in scalar assignment 123vec(%h,1,1) = 3; 124EXPECT 125Can't modify hash dereference in vec at - line 1, near "3;" 126Execution of - aborted due to compilation errors. 127######## 128# NAME vec %h in list assignment 129(vec %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 Can't declare conditional 135my($a?$b:$c) 136EXPECT 137Can't declare conditional expression in "my" at - line 1, at EOF 138Execution of - aborted due to compilation errors. 139######## 140# NAME Can't declare do block 141my(do{}) 142EXPECT 143Can't declare do block in "my" at - line 1, at EOF 144Execution of - aborted due to compilation errors. 145######## 146# NAME ($_, state $x) = ... 147($_, CORE::state $x) = (); 148EXPECT 149Initialization of state variables in list currently forbidden at - line 1, near ");" 150Execution of - aborted due to compilation errors. 151######## 152# NAME my $y; ($y, state $x) = ... 153my $y; ($y, CORE::state $x) = (); 154EXPECT 155Initialization of state variables in list currently forbidden at - line 1, near ");" 156Execution of - aborted due to compilation errors. 157######## 158# NAME delete BAD 159delete $x; 160EXPECT 161delete argument is not a HASH or ARRAY element or slice at - line 1. 162######## 163# NAME delete sort 164use warnings; 165delete sort 1; # used to warn about scalar context, too 166EXPECT 167delete argument is not a HASH or ARRAY element or slice at - line 2. 168######## 169# NAME exists BAD 170exists $x; 171EXPECT 172exists argument is not a HASH or ARRAY element or a subroutine at - line 1. 173######## 174# NAME exists non-sub 175exists &foo() 176EXPECT 177exists argument is not a subroutine name at - line 1. 178######## 179# NAME push BAREWORD 180push FRED; 181EXPECT 182Type of arg 1 to push must be array (not constant item) at - line 1, near "FRED;" 183Execution of - aborted due to compilation errors. 184######## 185# NAME pop BAREWORD 186pop FRED; 187EXPECT 188Type of arg 1 to pop must be array (not constant item) at - line 1, near "FRED;" 189Execution of - aborted due to compilation errors. 190######## 191# NAME shift BAREWORD 192shift FRED; 193EXPECT 194Type of arg 1 to shift must be array (not constant item) at - line 1, near "FRED;" 195Execution of - aborted due to compilation errors. 196######## 197# NAME unshift BAREWORD 198unshift FRED; 199EXPECT 200Type of arg 1 to unshift must be array (not constant item) at - line 1, near "FRED;" 201Execution of - aborted due to compilation errors. 202######## 203# NAME keys BAREWORD 204@a = keys FRED ; 205EXPECT 206Type of arg 1 to keys must be hash or array (not constant item) at - line 1, near "FRED ;" 207Execution of - aborted due to compilation errors. 208######## 209# NAME values BAREWORD 210@a = values FRED ; 211EXPECT 212Type of arg 1 to values must be hash or array (not constant item) at - line 1, near "FRED ;" 213Execution of - aborted due to compilation errors. 214######## 215# NAME each BAREWORD 216@a = each FRED ; 217EXPECT 218Type of arg 1 to each must be hash or array (not constant item) at - line 1, near "FRED ;" 219Execution of - aborted due to compilation errors. 220######## 221# NAME better messages for array-ops on non-arrays 222push %a, 1; 223pop %a; 224shift %a; 225unshift %a, 1; 226push *a, 1; 227pop *a; 228shift *a; 229unshift *a, 1; 230EXPECT 231Type of arg 1 to push must be array (not hash dereference) at - line 1, near "1;" 232Type of arg 1 to pop must be array (not hash dereference) at - line 2, near "%a;" 233Type of arg 1 to shift must be array (not hash dereference) at - line 3, near "%a;" 234Type of arg 1 to unshift must be array (not hash dereference) at - line 4, near "1;" 235Type of arg 1 to push must be array (not ref-to-glob cast) at - line 5, near "1;" 236Type of arg 1 to pop must be array (not ref-to-glob cast) at - line 6, near "*a;" 237Type of arg 1 to shift must be array (not ref-to-glob cast) at - line 7, near "*a;" 238Type of arg 1 to unshift must be array (not ref-to-glob cast) at - line 8, near "1;" 239Execution of - aborted due to compilation errors. 240######## 241# NAME better messages for array-ops on non-arrays (part 2) 242# to check PADHV without hitting the reported error limit 243my %a; 244push %a, 1; 245pop %a; 246shift %a; 247unshift %a, 1; 248EXPECT 249Type of arg 1 to push must be array (not private hash) at - line 3, near "1;" 250Type of arg 1 to pop must be array (not private hash) at - line 4, near "%a;" 251Type of arg 1 to shift must be array (not private hash) at - line 5, near "%a;" 252Type of arg 1 to unshift must be array (not private hash) at - line 6, near "1;" 253Execution of - aborted due to compilation errors. 254######## 255use feature 'defer'; 256no warnings 'experimental::defer'; 257defer { return "retval" } 258EXPECT 259Can't "return" out of a "defer" block at - line 3. 260######## 261use feature 'defer'; 262no warnings 'experimental::defer'; 263defer { goto HERE } 264HERE: 265EXPECT 266Can't "goto" out of a "defer" block at - line 3. 267######## 268use feature 'defer'; 269no warnings 'experimental::defer'; 270my $subB = sub {}; 271defer { goto &$subB } 272EXPECT 273Can't "goto" out of a "defer" block at - line 4. 274######## 275use feature 'defer'; 276no warnings 'experimental::defer'; 277LOOP: while(1) { 278 defer { last LOOP } 279} 280EXPECT 281Can't "last" out of a "defer" block at - line 4. 282######## 283use feature 'try'; 284no warnings 'experimental::try'; 285try {} catch ($e) {} finally { return "123" } 286EXPECT 287Can't "return" out of a "finally" block at - line 3. 288######## 289use feature 'try'; 290no warnings 'experimental::try'; 291try {} catch ($e) {} finally { goto HERE; } 292HERE: 293EXPECT 294Can't "goto" out of a "finally" block at - line 3. 295######## 296use feature 'try'; 297no warnings 'experimental::try'; 298LOOP: { 299 try {} catch ($e) {} finally { last LOOP; } 300} 301EXPECT 302Can't "last" out of a "finally" block at - line 4. 303