Skip to content

Commit

Permalink
Fix compile_in_context with an immediate block
Browse files Browse the repository at this point in the history
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 b9f8995
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Perl6/World.nqp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2783,16 +2783,22 @@ class Perl6::World is HLL::World {
} }


# Compile it, set wrapper's static lexpad, then invoke the wrapper, # 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( my $compunit := QAST::CompUnit.new(
:hll('perl6'), :hll('perl6'),
:sc(self.sc()), :sc(self.sc()),
:compilation_mode(0), :compilation_mode(0),
$wrapper $wrapper
); );
my $comp := nqp::getcomp('perl6'); my $comp := nqp::getcomp('perl6');
my $orig_blocktype := $past.blocktype;
$past.blocktype('declaration');
my $precomp := $comp.compile($compunit, :from<optimize>, :compunit_ok(1), my $precomp := $comp.compile($compunit, :from<optimize>, :compunit_ok(1),
:lineposcache($*LINEPOSCACHE)); :lineposcache($*LINEPOSCACHE));
$past.blocktype($orig_blocktype);
my $mainline := $comp.backend.compunit_mainline($precomp); my $mainline := $comp.backend.compunit_mainline($precomp);
$mainline(); $mainline();


Expand Down

0 comments on commit b9f8995

Please sign in to comment.