Skip to content

Commit

Permalink
RakuAST: fix missing post processors on heredocs
Browse files Browse the repository at this point in the history
We silently dropped the post processor from eg. q:w:to and treated it
like q:to. Fix by stealing not only the segments, but also the
processors from the temporary QuotedString object that gets generated.
  • Loading branch information
niner committed Jan 29, 2023
1 parent 775bdb2 commit fc9cbd3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Raku/Grammar.nqp
Expand Up @@ -182,6 +182,7 @@ role Raku::Common {
# Get it trimmed and AST updated.
my $heredoc := $herestub.orignode.MATCH.ast;
$heredoc.replace-segments-from($doc.MATCH.ast);
$heredoc.steal-processors-from($doc.MATCH.ast);
$heredoc.set-stop(~$stop);
my str $ws := $stop.MATCH<ws>.Str;
my int $actualchars := nqp::chars($ws);
Expand Down
15 changes: 15 additions & 0 deletions src/Raku/ast/literals.rakumod
Expand Up @@ -482,6 +482,21 @@ class RakuAST::Heredoc is RakuAST::QuotedString {
);
}

method steal-processors-from(RakuAST::QuotedString $source) {
my $processors := nqp::getattr(self, RakuAST::QuotedString, '$!processors');
for self.IMPL-UNWRAP-LIST($source.processors) {
nqp::push($processors, $_);
}
# Also steal the implicit lookups as any processor related lookups will
# have been done before we got to stealing those processors.
nqp::bindattr(
self,
RakuAST::ImplicitLookups,
'$!implicit-lookups-cache',
nqp::getattr($source, RakuAST::ImplicitLookups, '$!implicit-lookups-cache')
);
}

method set-stop(Str $stop) {
nqp::bindattr(self, RakuAST::Heredoc, '$!stop', $stop);
}
Expand Down

0 comments on commit fc9cbd3

Please sign in to comment.