Skip to content

Commit

Permalink
ck_open: report bareword dup handles under no feature bareword_fileha…
Browse files Browse the repository at this point in the history
…ndles
  • Loading branch information
tonycoz committed Sep 4, 2024
1 parent da66962 commit 6857aa1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions op.c
Original file line number Diff line number Diff line change
Expand Up @@ -13487,8 +13487,11 @@ Perl_ck_open(pTHX_ OP *o)
(oa = OpSIBLING(first)) && /* The fh. */
(oa = OpSIBLING(oa)) && /* The mode. */
S_is_dup_mode(oa) && /* A dup open. */
(last == OpSIBLING(oa))) /* The bareword. */
last->op_private &= ~OPpCONST_STRICT;
(last == OpSIBLING(oa))) { /* The bareword. */
if (!FEATURE_BAREWORD_FILEHANDLES_IS_ENABLED)
no_bareword_filehandle(SvPVX(cSVOPx_sv(last)));
last->op_private &= ~OPpCONST_STRICT;
}
}
{
/* mark as special if filename is a literal undef */
Expand Down
12 changes: 12 additions & 0 deletions t/lib/feature/bareword_filehandles
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,15 @@ Beta
stdout
>Delta
>Epsilon
########
# NAME bareword handle in open dup handle calls
use strict;
open BAREWORD, ">&", STDOUT;
open my $fh2, ">&", BAREWORD;
no feature "bareword_filehandles";
open my $fh3, ">&", STDOUT;
open my $fh4, ">&", BAREWORD;
EXPECT
OPTIONS fatal
Bareword filehandle "BAREWORD" not allowed under 'no feature "bareword_filehandles"' at - line 6.
Execution of - aborted due to compilation errors.

0 comments on commit 6857aa1

Please sign in to comment.