Skip to content

Commit

Permalink
Fix for #131386, spotted by zostay++
Browse files Browse the repository at this point in the history
An empty Baggy doesn't have the underlying hash allocated: we need
to keep thinking about that.  Please note that the binding to $raw
can go once we've made %!elems a low level hash itself.
  • Loading branch information
lizmat committed May 28, 2017
1 parent 8ec4dc5 commit 87d0e0a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/core/Baggy.pm
Expand Up @@ -121,13 +121,17 @@ my role Baggy does QuantHash {
}

multi method AT-KEY(Baggy:D: \k) { # exception: ro version for Bag/Mix
nqp::getattr(
nqp::ifnull(
nqp::atkey(self.raw_hash,k.WHICH),
BEGIN nqp::p6bindattrinvres(nqp::create(Pair),Pair,'$!value',0)
nqp::if(
(my $raw := self.raw_hash),
nqp::getattr(
nqp::ifnull(
nqp::atkey($raw,k.WHICH),
BEGIN nqp::p6bindattrinvres(nqp::create(Pair),Pair,'$!value',0)
),
Pair,
'$!value'
),
Pair,
'$!value'
0
)
}
multi method DELETE-KEY(Baggy:D: \k) {
Expand Down

0 comments on commit 87d0e0a

Please sign in to comment.