Skip to content

Commit

Permalink
Fix for RT #126951
Browse files Browse the repository at this point in the history
Sorry, this appears to have fallen through the cracks.

Please note though that a FLATTENABLE_HASH cannot represent all
object hashes correctly, only the ones that happen to have Str for
keys.  If the key is not a Str, it will be coerced to Str in the
returned hash
  • Loading branch information
lizmat committed Aug 26, 2017
1 parent 3518b13 commit 6cec6b7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/core/Hash.pm
Expand Up @@ -641,6 +641,37 @@ my class Hash { # declared in BOOTSTRAP
TValue
)
}

method FLATTENABLE_HASH() {
nqp::stmts(
(my $flattened := nqp::hash),
nqp::if(
(my $raw := nqp::getattr(self,Map,'$!storage'))
&& (my $iter := nqp::iterator($raw)),
nqp::while(
$iter,
nqp::bindkey(
$flattened,
nqp::if(
nqp::istype(
(my $key := nqp::getattr(
nqp::iterval(nqp::shift($iter)),
Pair,
'$!key'
)),
Str,
),
$key,
$key.Str
),
nqp::getattr(nqp::iterval($iter),Pair,'$!value')
)
)
),
$flattened
)
}

method IterationBuffer() {
nqp::stmts(
(my $buffer := nqp::create(IterationBuffer)),
Expand Down

0 comments on commit 6cec6b7

Please sign in to comment.