# New Ticket Created by Patrick R. Michaud # Please include the string: [perl #56622] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=56622 >
This one takes a bit of lengthy explanation, but the bottom line is that the 'isa' opcode can returns different results when given a String PMC versus a string register or constant. Here's a sample program, run against r29086 (the code is explained below): $ cat w2.pir .sub main :main .local pmc xyzns, xyzclass, xyzobj xyzns = get_root_namespace ['foo';'XYZ'] xyzclass = newclass xyzns xyzobj = new xyzclass ## prove that it's the correct type xyzobj.'abc'() ## test two forms of isa $P0 = new 'String' $P0 = 'XYZ' $I0 = isa xyzobj, 'XYZ' say $I0 $I0 = isa xyzobj, $P0 say $I0 .end .HLL 'foo', '' .namespace ['XYZ'] .sub 'abc' :method say 'XYZ::abc' .end This code is creating a class within another HLL namespace ('foo'). To do this we first get the ['foo';'XYZ'] namespace and use that as an argument to the newclass opcode. We then use that class to create xyzobj, and test that we can properly invoke the method. After that we test "isa XYZ" using a string constant and a String PMC. The output of the above program is: $ ./parrot w2.pir XYZ::abc 1 0 As you can see, the two 'isa' opcodes return different results. This doesn't happen if 'isa' is being used from the same HLL namespace as the class itself: If the .HLL line is moved to the top of the file (thus placing sub 'main' in the same HLL namespace), or if the .HLL line is removed and we change the get_root_namespace line to read from ['parrot';'XYZ'], then the two isa opcodes return the same value. This report strictly questions the inconsistency of results when 'isa' is given a string versus a String PMC, without any comment about whether the above should be 0 in both cases or 1 in both cases. I can make an argument for either answer. It's just that it seems the two forms of isa ought to return the same answer, or that we make it clear why they differ. Thanks! Pm