Skip to content

Commit eeb4f43

Browse files
committed
Fix BEGIN time EVAL accidentally running CHECK phasers of the outer comp unit
This could cause wird compilation errors about missing static code refs for closures. Fix by simply not sharing the list of CHECK blocks with a nested compiler.
1 parent 4085cfd commit eeb4f43

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

src/Perl6/World.nqp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,6 @@ class Perl6::World is HLL::World {
222222
has $!the_whatever;
223223
has $!the_hyper_whatever;
224224

225-
# List of CHECK blocks to run.
226-
has @!CHECKs;
227-
228225
# Clean-up tasks, to do after CHECK time.
229226
has @!cleanup_tasks;
230227

@@ -237,7 +234,6 @@ class Perl6::World is HLL::World {
237234
@!CODES := [];
238235
@!stub_check := [];
239236
@!protos_to_sort := [];
240-
@!CHECKs := [];
241237
%!sub_id_to_code_object := {};
242238
%!sub_id_to_cloned_code_objects := {};
243239
%!sub_id_to_sc_idx := {};
@@ -482,14 +478,6 @@ class Perl6::World is HLL::World {
482478
$!the_hyper_whatever := $hyper_whatever
483479
}
484480

485-
method add_check($check) {
486-
@!CHECKs := [] unless @!CHECKs;
487-
@!CHECKs.unshift($check);
488-
}
489-
490-
method checks() {
491-
@!CHECKs
492-
}
493481
}
494482

495483
method context_class() {
@@ -521,12 +509,16 @@ class Perl6::World is HLL::World {
521509
has $!setting_name;
522510
has $!setting_revision;
523511

512+
# List of CHECK blocks to run.
513+
has @!CHECKs;
514+
524515
method BUILD(*%adv) {
525516
%!code_object_fixup_list := {};
526517
$!record_precompilation_dependencies := 1;
527518
%!quote_lang_cache := {};
528519
$!setting_loaded := 0;
529520
$!in_unit_parse := 0;
521+
@!CHECKs := [];
530522
}
531523

532524
method create_nested() {
@@ -551,6 +543,15 @@ class Perl6::World is HLL::World {
551543
$!in_unit_parse
552544
}
553545

546+
method add_check($check) {
547+
@!CHECKs := [] unless @!CHECKs;
548+
@!CHECKs.unshift($check);
549+
}
550+
551+
method checks() {
552+
@!CHECKs
553+
}
554+
554555
method !check-version-modifier($ver-match, $rev, $modifier, $comp) {
555556
my %lang_rev := $comp.language_revisions;
556557

@@ -4309,7 +4310,7 @@ class Perl6::World is HLL::World {
43094310
self.handle-begin-time-exceptions($/, 'evaluating a CHECK', $block);
43104311
}
43114312
my $result_node := QAST::Stmt.new( QAST::Var.new( :name('Nil'), :scope('lexical') ) );
4312-
self.context().add_check([$handled_block, $result_node]);
4313+
self.add_check([$handled_block, $result_node]);
43134314
return $result_node;
43144315
}
43154316
elsif $phaser eq 'INIT' {
@@ -4411,7 +4412,7 @@ class Perl6::World is HLL::World {
44114412

44124413
# Runs the CHECK phasers and twiddles the QAST to look them up.
44134414
method CHECK() {
4414-
for self.context().checks() {
4415+
for self.checks() {
44154416
my $result := $_[0]();
44164417
$_[1][0] := self.add_constant_folded_result($result);
44174418
}

t/02-rakudo/16-begin-time-eval.t

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use lib <t/packages/02-rakudo/lib>;
2+
use Test;
3+
use BeginTimeEvalAndNativeCall;
4+
pass 'Module loaded successfully';
5+
done-testing;

0 commit comments

Comments
 (0)