Ticket #1295 (closed RFC: wontfix)
Should FixedPMCArray autovivify nested arrays on set_*keyed()?
| Reported by: | whiteknight | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | core | Version: | 1.7.0 |
| Severity: | medium | Keywords: | |
| Cc: | jkeenan | Language: | |
| Patch status: | Platform: |
Description
(From RT #46675)
Here is an example of code:
VTABLE void set_pmc_keyed(PMC *key, PMC *value) {
const INTVAL k = VTABLE_get_integer(INTERP, key);
PMC *nextkey = key_next(INTERP, key);
if (!nextkey) {
SELF.set_pmc_keyed_int(k, value);
}
else {
PMC *box = SELF.get_pmc_keyed_int(k);
/* RT #46675: autovivify an Array and insert it in SELF */
if (!box)
box = pmc_new(INTERP, SELF.type());
VTABLE_set_pmc_keyed(INTERP, box, nextkey, value);
}
}
It's clear from the code above that if the element at SELF[k] doesn't exist, that a new array is created, but that new array is never inserted into SELF. So the question is this: What is the expected autovivification behavior of FixedPMCArray (and, by extension, the other Fixed*Array types)?
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

