On Thu Dec 04 04:35:43 2008, pmichaud wrote:
> On Wed, Dec 03, 2008 at 03:54:16PM -0800, Carl Mäsak wrote:
> > # New Ticket Created by  "Carl Mäsak" 
> > # Please include the string:  [perl #61034]
> > # in the subject line of all future correspondence about this issue. 
> > # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=61034 >
> > 
> > 
> > Rakudo r33458:
> > 
> > $ ./perl6 -e 'my $a = do given 5 {}'
> > Null PMC access in isa()
> > [...]
> > Segmentation fault
> > 
> > As soon as the given block contains _something_ (when, default, or
> > just about anything else), the error goes away.
> 
> Rakudo probably thinks the {} is an empty hash, and gets all
> confused from there.
> 

Turns out not - the problem actually is that for empty blocks with no
statements in, we emitted a:

.return ()

Which meant that the thingy calling it got a Null PMC. infix:= then did
an isa on it, which then gave the error.

Where to fix this takes some care - since a block may get transformed
into a hash composer, we can't just give every block that is empty an
undef in somewhere like, say, the pblock action (well, we can, but only
if it actually has a lambda). Anyway, I wrote a routine to do this and
called it from xblock and in pblock if we have a lambda, which fixes the
original bug, the following:

my $x = -> {}; my $y = $x();

And no doubt a variety of other Null PMC accesses that could have
happened. And of course, it passes the spectests. So, in as git 9a5c690,
and assigning to moritz++ for tests.

Thanks,

Jonathan

Reply via email to