Skip to content

ck_open: report bareword dup handles under no feature bareword_filehandles #22568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.