Skip to content

Bugs in clone, sugar methods, and postdec #6

Description

@xdg

Hi David,

A. The clone method upon receiving duplicate keys returns a cloned object with duplicate keys inside [_KEYS]. This is similar to a prior bug in ->new.

$copy = $ho->clone(qw/ k1 k2 k2 k3 /); # [_KEYS] has "k2" twice

B. Sugar methods do not check if the key exists in [_DATA].

$ho = Hash::Ordered->new();
$ho->preinc("counter"); # "counter" is missing in [_KEYS]

C. ->postdec returns undef the first time. Interestingly, postinc returns 0 even though not doing // 0 or || 0 inside the code. It appears that Perl isn't consistent with post -- and ++ to an undefined value.

perli> $ho = Hash::Ordered->new
bless( [
{},
[],
undef,
0,
0
], 'Hash::Ordered' )

perli> $ho->postinc("key1")
0

perli> $ho->postdec("key2")
undef

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions