Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ensure Capture.perl doesn't flatten in hashes.
Fixes RT #114100.
  • Loading branch information
jnthn committed Apr 28, 2015
1 parent b6b180b commit 71d6480
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/core/Capture.pm
Expand Up @@ -91,19 +91,18 @@ my class Capture { # declared in BOOTSTRAP
}
multi method gist(Capture:D:) { self.perl }
multi method perl(Capture:D:) {
my @list := self.list;
my %hash := self.hash;
if self.^name eq 'Capture' {
"\\({
join ', ',
(@list[$_].perl for ^@list.elems),
(nqp::atpos($!list, $_).perl for ^nqp::elems($!list)),
%hash.sort.map( *.perl )
})";
} else {
self.^name
~ '.new('
~ ( 'list => (' ~ (@list[$_].perl for ^@list.elems).join(', ') ~ ',)' if +@list)
~ (', ' if +@list and +%hash)
~ ( 'list => (' ~ (nqp::atpos($!list, $_).perl for ^nqp::elems($!list)).join(', ') ~ ',)' if $!list)
~ (', ' if +$!list and +%hash)
~ ( 'hash => {' ~ %hash.sort.map( *.perl ).join(', ') ~ '}' if +%hash)
~ ')';
}
Expand Down

0 comments on commit 71d6480

Please sign in to comment.