Stop set-magic from being called after ref-to-glob assignment.
handles from their parent threads
L<[perl #75154]|http://rt.perl.org/rt3/Public/Bug/Display.html?id=75154>.
+=item *
+
+Assignment through a glob no longer triggers set-magic on the glob itself
+L<[perl #77928]|http://rt.perl.org/rt3/Public/Bug/Display.html?id=77928>.
+
=back
=head1 Known Problems
SvSetSV_nosteal_and(dst,src,/*nothing*/;)
#define SvSetMagicSV(dst,src) \
- SvSetSV_and(dst,src,SvSETMAGIC(dst))
+ SvSetSV_and(dst,src, \
+ if (SvSMAGICAL(dst) \
+ && ( \
+ !isGV_with_GP(dst) || !SvROK(src) || isGV_with_GP(SvRV(src)) \
+ ) \
+ ) \
+ mg_set(dst) \
+ )
#define SvSetMagicSV_nosteal(dst,src) \
- SvSetSV_nosteal_and(dst,src,SvSETMAGIC(dst))
+ SvSetSV_nosteal_and(dst,src, \
+ if (SvSMAGICAL(dst) \
+ && ( \
+ !isGV_with_GP(dst) || !SvROK(src) || isGV_with_GP(SvRV(src)) \
+ ) \
+ ) \
+ mg_set(dst) \
+ )
#if !defined(SKIP_DEBUGGING)
use warnings;
-plan( tests => 219 );
+plan( tests => 220 );
# type coersion on assignment
$foo = 'foo';
}}->($h{k});
}
+# [perl #77928] Glob slot assignment and set-magic
+{
+ package Readonly::Alias;
+ sub TIESCALAR { bless \(my $x = \pop) }
+ sub FETCH { $${$_[0]} }
+ sub STORE { die "Assignment to read-only value" }
+ package main;
+ tie my $alias, "Readonly::Alias", my $var;
+ $var = *bength;
+ # Now modify a glob slot, not the alias itself:
+ ok(scalar eval { *$alias = [] }, 'glob slot assignment skips set-magic');
+}
+
__END__
Perl
Rules