Ticket #1999 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

Parrot_PMC_get_pmc : Does it work correctly?

Reported by: dukeleto Owned by: dukeleto
Priority: normal Milestone:
Component: embed/extend Version: 3.0.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform: all

Description (last modified by dukeleto) (diff)

I added the following test here

 https://github.com/parrot/parrot/commit/ac2ad789fc094d33a9db1f984e85ed100047be49

# TODO: Is this test correct?
extend_vtable_output_is(<<'CODE', <<'OUTPUT', "Parrot_PMC_get_pmc");
    Parrot_PMC_set_integer_native(interp, pmc, 42);
    Parrot_PMC_push_pmc(interp, rpa, pmc);
    Parrot_PMC_push_pmc(interp, rpa, pmc);
    Parrot_PMC_push_pmc(interp, rpa, pmc);

    pmc3 = Parrot_PMC_get_iter(interp, rpa);
    pmc2 = Parrot_PMC_get_pmc(interp, pmc3);
    Parrot_printf(interp,"%P\n", pmc2);
CODE
3
Done!
OUTPUT

It currently passes, but is it correct? i.e. If get_pmc is called on a RPA iterator, should it return the number of elements in the RPA?

Change History

Changed 3 years ago by dukeleto

  • owner set to dukeleto
  • status changed from new to assigned
  • component changed from none to embed/extend
  • description modified (diff)

Changed 3 years ago by cotto

After a bit of digging, here's what's happening. VTABLE_get_pmc on ArrayIterator returns the array-like PMC being iterated, which is sensible. The confusion comes from the fact that Parrot_printf (after many layers of magic and gotos) calls VTABLE_get_string in the array, which returns a stringification of the number of elements in the array. In the example above, looking at the type of pmc2 will make it clearer what's happening.

Changed 3 years ago by dukeleto

  • status changed from assigned to closed
  • resolution set to invalid

This ended up being me not understanding stuff. No bugs here, move along, nothing to see here.

Note: See TracTickets for help on using tickets.