Skip to content

Commit

Permalink
Make overloaded constants always read-only
Browse files Browse the repository at this point in the history
They were not read-only if the constant handler returned a shared
hash key scalar.

This was brought up in bug #109744.
  • Loading branch information
Father Chrysostomos committed Jul 26, 2013
1 parent a888bde commit 1913067
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion lib/overload.t
Expand Up @@ -1301,7 +1301,6 @@ foreach my $op (qw(<=> == != < <= > >=)) {
'constant overloading makes read-only constants';
BEGIN { overload::constant integer => sub { __PACKAGE__ }; }
eval { ${\5} = 'whatever' };
local $::TODO = ' ';
like $@, qr/^Modification of a read-only value attempted at /,
'... even with shared hash key scalars';
}
Expand Down
2 changes: 1 addition & 1 deletion op.c
Expand Up @@ -10562,7 +10562,7 @@ Perl_ck_svconst(pTHX_ OP *o)
{
PERL_ARGS_ASSERT_CK_SVCONST;
PERL_UNUSED_CONTEXT;
if (!SvIsCOW(cSVOPo->op_sv)) SvREADONLY_on(cSVOPo->op_sv);
SvREADONLY_on(cSVOPo->op_sv);
return o;
}

Expand Down

0 comments on commit 1913067

Please sign in to comment.