Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix .perl on mutually referencing object structures
Port the fix from List to Mu for wider applicability.
Fixes RT #122286
  • Loading branch information
niner committed Sep 24, 2015
1 parent 855512f commit 397e221
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/Mu.pm
Expand Up @@ -348,14 +348,19 @@ Please refactor this code using the new Iterator / Seq interface.
proto method perl(|) { * }
multi method perl(Mu:U:) { self.^name }
multi method perl(Mu:D:) {
if not %*perlseen<TOP> { my %*perlseen = :TOP ; return self.perl }
if %*perlseen{self.WHICH} { %*perlseen{self.WHICH} = 2; return "{self.^name}_{self.WHERE}" }
%*perlseen{self.WHICH} = 1;
my @attrs;
for self.^attributes().flat.grep: { .has_accessor } -> $attr {
my $name := substr($attr.Str,2);
@attrs.push: $name
~ ' => '
~ $attr.get_value(self).perl
}
self.^name ~ '.new' ~ ('(' ~ @attrs.join(', ') ~ ')' if @attrs)
my $result = self.^name ~ '.new' ~ ('(' ~ @attrs.join(', ') ~ ')' if @attrs);
$result = "(my \\{self.^name}_{self.WHERE} = $result)" if %*perlseen{self.WHICH}:delete == 2;
$result;
}

proto method DUMP(|) { * }
Expand Down

0 comments on commit 397e221

Please sign in to comment.