Skip to content

Commit

Permalink
RakuAST: allow constant terms to be used in rakudoc config
Browse files Browse the repository at this point in the history
By attempting to resolve RakuAST::Term::Name when literalizing,
and use that value if successful.
  • Loading branch information
lizmat committed Jun 18, 2023
1 parent c14c725 commit c884b16
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/core.c/RakuAST/Literalize.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,24 @@ augment class RakuAST::Node {
multi method literalize(RakuAST::Term::Name:D:) {
my str $name = self.name.canonicalize;

$name eq 'True'
?? True
!! $name eq 'False'
?? False
!! self.resolution.compile-time-value
if $name eq 'True' {
True
}
elsif $name eq 'False' {
False
}
else {
unless self.is-resolved {
self.resolve-with($_) with $*RESOLVER;
}

with try self.resolution andthen .compile-time-value {
$_
}
else {
CannotLiteralize.new.throw;
}
}
}

multi method literalize(RakuAST::Term::RadixNumber:D:) {
Expand Down

0 comments on commit c884b16

Please sign in to comment.