File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -13228,6 +13228,24 @@ Perl_ck_grep(pTHX_ OP *o)
13228
13228
Perl_croak(aTHX_ "panic: ck_grep, type=%u", (unsigned) kid->op_type);
13229
13229
kid = kUNOP->op_first;
13230
13230
13231
+ switch(o->op_type) {
13232
+ case OP_ANYSTART:
13233
+ case OP_ALLSTART:
13234
+ /* any { BLOCK } would create an OP_NULL[OP_SCOPE[...]] or
13235
+ * OP_NULL[OP_LEAVE[...]] here. If we don't see this structure
13236
+ * then it must have been any EXPR, ... which we forbid
13237
+ * TODO: See if we can forbid this somehow in perly.y itself
13238
+ */
13239
+ if(!OP_TYPE_IS(kid, OP_NULL) ||
13240
+ !(OP_TYPE_IS(kUNOP->op_first, OP_SCOPE) || OP_TYPE_IS(kUNOP->op_first, OP_LEAVE))) {
13241
+ /* diag_listed_as: any EXPR, LIST is not allowed */
13242
+ /* diag_listed_as: all EXPR, LIST is not allowed */
13243
+ croak("%s EXPR, LIST is not allowed",
13244
+ o->op_type == OP_ANYSTART ? "any" : "all");
13245
+ }
13246
+ break;
13247
+ }
13248
+
13231
13249
gwop = alloc_LOGOP(type, o, LINKLIST(kid));
13232
13250
kid->op_next = (OP*)gwop;
13233
13251
o->op_private = gwop->op_private = 0;
Original file line number Diff line number Diff line change @@ -75,6 +75,14 @@ removed in a future Perl version:
75
75
use feature "refaliasing";
76
76
\$x = \$y;
77
77
78
+ =item all EXPR, LIST is not allowed
79
+
80
+ (F) An attempt was made to use the C<all> keyword with a deferred expression,
81
+ which is permitted for C<grep> but not for C<all>. You need to put the
82
+ expression in a block instead, as
83
+
84
+ $result = all { EXPR } LIST;
85
+
78
86
=item all is experimental
79
87
80
88
(S experimental::any_all) This warning is emitted if you use the C<all>
@@ -188,6 +196,14 @@ which 'splits' output into two streams, such as
188
196
}
189
197
close OUT;
190
198
199
+ =item any EXPR, LIST is not allowed
200
+
201
+ (F) An attempt was made to use the C<any> keyword with a deferred expression,
202
+ which is permitted for C<grep> but not for C<any>. You need to put the
203
+ expression in a block instead, as
204
+
205
+ $result = any { EXPR } LIST;
206
+
191
207
=item any is experimental
192
208
193
209
(S experimental::any_all) This warning is emitted if you use the C<any>
Original file line number Diff line number Diff line change @@ -326,3 +326,17 @@ use 5.012;
326
326
use 5.010;
327
327
EXPECT
328
328
Downgrading a use VERSION declaration to below v5.11 is not permitted at - line 3.
329
+ ########
330
+ # any with deferred LIST expression
331
+ use feature 'any_all';
332
+ no warnings 'experimental::any_all';
333
+ any length, qw( a b c )
334
+ EXPECT
335
+ any EXPR, LIST is not allowed at - line 4.
336
+ ########
337
+ # all with deferred LIST expression
338
+ use feature 'any_all';
339
+ no warnings 'experimental::any_all';
340
+ all length, qw( a b c )
341
+ EXPECT
342
+ all EXPR, LIST is not allowed at - line 4.
You can’t perform that action at this time.
0 commit comments