Skip to content

Commit 2fe89a7

Browse files
committed
ck_open: report bareword dup handles under no feature bareword_filehandles
1 parent da66962 commit 2fe89a7

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

op.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13487,8 +13487,11 @@ Perl_ck_open(pTHX_ OP *o)
1348713487
(oa = OpSIBLING(first)) && /* The fh. */
1348813488
(oa = OpSIBLING(oa)) && /* The mode. */
1348913489
S_is_dup_mode(oa) && /* A dup open. */
13490-
(last == OpSIBLING(oa))) /* The bareword. */
13491-
last->op_private &= ~OPpCONST_STRICT;
13490+
(last == OpSIBLING(oa))) { /* The bareword. */
13491+
if (!FEATURE_BAREWORD_FILEHANDLES_IS_ENABLED)
13492+
no_bareword_filehandle(SvPVX(cSVOPx_sv(last)));
13493+
last->op_private &= ~OPpCONST_STRICT;
13494+
}
1349213495
}
1349313496
{
1349413497
/* mark as special if filename is a literal undef */

t/lib/feature/bareword_filehandles

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,3 +556,15 @@ Beta
556556
stdout
557557
>Delta
558558
>Epsilon
559+
########
560+
# NAME bareword handle in open dup handle calls
561+
use strict;
562+
open BAREWORD, ">&", STDOUT;
563+
open my $fh2, ">&", BAREWORD;
564+
no feature "bareword_filehandles";
565+
open my $fh3, ">&", STDOUT;
566+
open my $fh4, ">&", BAREWORD;
567+
EXPECT
568+
OPTIONS fatal
569+
Bareword filehandle "BAREWORD" not allowed under 'no feature "bareword_filehandles"' at - line 6.
570+
Execution of - aborted due to compilation errors.

0 commit comments

Comments
 (0)
close