Change 18486 by rgs@rgs-home on 2003/01/15 20:34:52 isa() and can() didn't work on magic variables see Message-Id: <[EMAIL PROTECTED]> plus a test case by B. Goldberg
Affected files ... ... //depot/perl/t/op/universal.t#21 edit ... //depot/perl/universal.c#60 edit Differences ... ==== //depot/perl/t/op/universal.t#21 (xtext) ==== Index: perl/t/op/universal.t --- perl/t/op/universal.t#20~14423~ Fri Jan 25 14:08:09 2002 +++ perl/t/op/universal.t Wed Jan 15 12:34:52 2003 @@ -9,7 +9,7 @@ $| = 1; } -print "1..94\n"; +print "1..98\n"; $a = {}; bless $a, "Bob"; @@ -173,4 +173,17 @@ main::test isa "Pickup", UNIVERSAL; main::test can( "Pickup", "can" ) == \&UNIVERSAL::can; main::test VERSION "UNIVERSAL" ; +} + +{ + # test isa() and can() on magic variables + "Human" =~ /(.*)/; + test $1->isa("Human"); + test $1->can("eat"); + package HumanTie; + sub TIESCALAR { bless {} } + sub FETCH { "Human" } + tie my($x), "HumanTie"; + ::test $x->isa("Human"); + ::test $x->can("eat"); } ==== //depot/perl/universal.c#60 (text) ==== Index: perl/universal.c --- perl/universal.c#59~18456~ Tue Jan 7 01:20:22 2003 +++ perl/universal.c Wed Jan 15 12:34:52 2003 @@ -232,7 +232,8 @@ if (SvGMAGICAL(sv)) mg_get(sv); - if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv)))) + if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv)) + || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv)))) XSRETURN_UNDEF; name = (char *)SvPV(ST(1),n_a); @@ -258,7 +259,8 @@ if (SvGMAGICAL(sv)) mg_get(sv); - if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv)))) + if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv)) + || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv)))) XSRETURN_UNDEF; name = (char *)SvPV(ST(1),n_a); End of Patch.