Skip to content
Permalink
Browse files

Fix compile_in_context with an immediate block

This situation could occur in the case of a begin-time EVAL that had a
code expression that contained an immediate QAST block. This led to the
failed $_ lookup reported in #2779, meaning that compilation of that
module no longer fails. Unfortunately, that isn't enough to make it
actually work, but it's a step closer.
  • Loading branch information...
jnthn committed May 14, 2019
1 parent ec97878 commit b9f899541b3f153ea73e33269eb53ec34ddf9280
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/Perl6/World.nqp
@@ -2783,16 +2783,22 @@ class Perl6::World is HLL::World {
}

# Compile it, set wrapper's static lexpad, then invoke the wrapper,
# which fixes up the lexicals.
# which fixes up the lexicals. For the duration of this compilation,
# we force the block type to declaration just to make sure we really
# only compile it, not run it (can happen if we're asking to compile
# an immediate block).
my $compunit := QAST::CompUnit.new(
:hll('perl6'),
:sc(self.sc()),
:compilation_mode(0),
$wrapper
);
my $comp := nqp::getcomp('perl6');
my $orig_blocktype := $past.blocktype;
$past.blocktype('declaration');
my $precomp := $comp.compile($compunit, :from<optimize>, :compunit_ok(1),
:lineposcache($*LINEPOSCACHE));
$past.blocktype($orig_blocktype);
my $mainline := $comp.backend.compunit_mainline($precomp);
$mainline();

0 comments on commit b9f8995

Please sign in to comment.
You can’t perform that action at this time.