Skip to content

Commit

Permalink
RakuAST: fix bizarre miscompilations of role bodies
Browse files Browse the repository at this point in the history
When roles are applied to classes within the same comp unit as they are
declared, they need to be fully compiled as their bodies are run when
the class is composed. However we only ran resolving, but did not apply
check time effects, so we e.g. did not thunk for loop expressions.

It looks like check time effects should just not modify the AST, i.e. not
try to thunk anything. That's better done as begin time effects as those
are guaranteed to run only once. Not sure if this will hold, but for now
it gets us further in the tests.
  • Loading branch information
niner committed Jan 23, 2023
1 parent 8589e80 commit 0b0bce8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Raku/ast/statements.rakumod
Expand Up @@ -434,7 +434,7 @@ class RakuAST::Statement::Expression
is RakuAST::SinkPropagator
is RakuAST::Sinkable
is RakuAST::BlockStatementSensitive
is RakuAST::CheckTime
is RakuAST::BeginTime
{
has RakuAST::Expression $.expression;
has RakuAST::StatementModifier::Condition $.condition-modifier;
Expand Down Expand Up @@ -514,7 +514,7 @@ class RakuAST::Statement::Expression
}
}

method PERFORM-CHECK(RakuAST::Resolver $resolver, RakuAST::IMPL::QASTContext $context) {
method PERFORM-BEGIN(RakuAST::Resolver $resolver, RakuAST::IMPL::QASTContext $context) {
if $!loop-modifier {
my $thunk := $!loop-modifier.expression-thunk;
$!expression.wrap-with-thunk($thunk) if $thunk;
Expand Down

0 comments on commit 0b0bce8

Please sign in to comment.