fix issues in hash assignment with odd elements
authorRuslan Zakirov <ruz@bestpractical.com>
Mon, 8 Oct 2012 13:32:24 +0000 (17:32 +0400)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 11 Dec 2012 16:59:40 +0000 (08:59 -0800)
commit1baa394bebe0d74f5a4f14772cc9000d6bdc99f7
treefb86c9fe73512735fba9af5be271b1cfd042c1fa
parent499ace3b7bbe6fb3aa489db1fb760ac0a6dbbd1b
fix issues in hash assignment with odd elements

1) unify code path of processing odd case with regular
loop that process pairs. fixes memory leak when key
is magic and dies on fetch.

2) in list context put undef that we added to compensate
odd elements into returned values, so (%h = (1))
returns (1, $h{1}) rather than (1). This is documented
in perldoc perlop:

    a list assignment in list context produces the list
    of lvalues assigned to.

Here can be a dispute, but:

* that key without value on RHS is still assigned with
  undef
* consider (%h = (1,2,3,4,5,6,3)). Returning (1,2,3,undef,5,6)
  is much easier than (1,2,5,6,3).
* order of returned elements follows cases with even number
  of elements on RHS and duplicates

3) hash assignment with duplicates and odd elements on
RHS was returning wrong results in list context.
Now (%h = (1,1,1)) returns (1,$h{1}).
pp_hot.c