petdance/scratch — Issue #92: isa does not take (correctly) namespace, pmcarray,stringarray
Author: petdance
Created: 2011-11-14 05:54:54+00:00
State: open
Labels: bug, core, Pri-normal, Sev-medium

When running this code isa returns true while it should return false
$P1 = #object of type 'FOO::BAR::TEST'

$P3 = get_hll_namespace [ 'FOO';'BAR2';'Object']

$I1 = isa $P1,$P3

returns true must be false

$P3 = string array with elements "FOO","BAR","TEST"

$I1 = isa $P1,$P3

returns fasle must be true

I solved this problem by replacing the

VTABLE INTVAL isa_pmc(PMC *lookup)

function with the following code

VTABLE INTVAL isa_pmc(PMC *lookup) {

Hash * const isa_hash = SELF->vtable->isa_hash;

+ PMC *classobj;

STRING *pmc_name;

if (PMC_IS_NULL(lookup))

return 0;

+ classobj = Parrot_oo_get_class(interp, lookup);

+ if (PMC_IS_NULL(classobj))

+ return 0;

-+ pmc_name = VTABLE_get_string(interp, classobj);

if (!isa_hash)

return Parrot_str_equal(interp, SELF->vtable->whoami, pmc_name);

/* RT #46665 - walk mro */

return parrot_hash_exists(INTERP, isa_hash, (void*)pmc_name);

}

I'am not sure it's completely correct, because i do not know how the mro isa_hash is build up.

Adding this code will make 2 test failing in the t/tests/objects.t test set, because there are more bugs present, I made seperate ticket for that one

Originally http://trac.parrot.org/parrot/ticket/879