Commit f04471cfc0 for perl
commit f04471cfc05ff651aed3e9e5fa6734928b9de9eb
Author: Tony Cook <tony@develop-help.com>
Date: Thu Oct 29 14:00:15 2026 +1100
isa: handle magic on the first parameter
sv_isa_sv() claims not to handle magic on the first parameter, and
doesn't within itself, but the call to sv_derived_from_pvn() will
invoke get magic, as will any underlying call to an overridden isa().
diff --git a/pp.c b/pp.c
index 909e050653..835c179b08 100644
--- a/pp.c
+++ b/pp.c
@@ -8771,6 +8771,8 @@ PP_wrapped(pp_isa, 2, 0)
right = POPs;
left = TOPs;
+ /* sv_isa_sv() doesn't believe in magic - but we have to */
+ SvGETMAGIC(left);
SETs(boolSV(sv_isa_sv(left, right)));
RETURN;
diff --git a/t/op/isa.t b/t/op/isa.t
index 42a993acaf..26d249fc12 100644
--- a/t/op/isa.t
+++ b/t/op/isa.t
@@ -10,7 +10,7 @@ BEGIN {
use strict;
use feature 'isa';
-plan 14;
+plan 16;
package BaseClass {}
package DerivedClass { our @ISA = qw(BaseClass) }
@@ -50,5 +50,20 @@ ok($baseobj->isa('BaseClass'), '$baseobj isa BaseClass using object method');
ok(not($baseobj->isa('DerivedClass')), '$baseobj is not BaseClass using object method');
ok($derivedobj->isa('BaseClass'), '$derivedobj isa BaseClass using object method');
+{
+ my $val;
+ # do we believe in magic?
+ package T {
+ sub TIESCALAR { bless {}, shift }
+ sub FETCH { $val }
+ }
+ my $x;
+ tie $x, "T";
+ $val = $baseobj;
+ ok($x isa "BaseClass", "isa believes in magic");
+ $val = 1;
+ ok(!($x isa "BaseClass"), "isa believes for non-refs");
+}
+
# TODO: Consider
# LHS = other class