Skip to content

Commit

Permalink
Fix crash in Proxy.perl
Browse files Browse the repository at this point in the history
Phixes #1466

The crash occurs due to `self` of a Proxy-ed object being conted,
but access to it fetches the value. So we end up entering .perl
via Mu:D candidate (the Proxy object itself) and then calling
.perlseen method on it (thus on the fetched value). So if that value
is a :U, then we explode, because there ain't no :U .perlseen candidate.
If the value is a :D, we'd generate incorrect .perl for many types.

Fix by checking if `self` is conted to discern when we're dealing
with a Proxy and then calling .perl on the fetched value. Not 100% sure
it should behave like that, rather than giving some sort of
"Proxy.new: …" value.
  • Loading branch information
zoffixznet committed Feb 2, 2018
1 parent 6266fd5 commit 902f45f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/core/Mu.pm
Expand Up @@ -642,15 +642,17 @@ Perhaps it can be found at https://docs.perl6.org/type/$name"
nqp::if(
nqp::eqaddr(self,IterationEnd),
"IterationEnd",
self.perlseen(self.^name, {
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)
})
)
nqp::if(
nqp::iscont(self), # a Proxy object would have a conted `self`
nqp::decont(self).perl,
self.perlseen: self.^name, {
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)
}))
}

proto method DUMP(|) {*}
Expand Down

0 comments on commit 902f45f

Please sign in to comment.