Skip to content

Commit

Permalink
RakuAST: fix deparse/raku of RakuAST::Name::Part::Expression
Browse files Browse the repository at this point in the history
Well, actually the canonicalization of RakuAST::Name::Part::Expression
  • Loading branch information
lizmat committed Mar 12, 2023
1 parent a5be6d2 commit b685e67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Raku/ast/name.rakumod
Expand Up @@ -112,7 +112,8 @@ class RakuAST::Name
nqp::push_s($canon-parts, '');
}
elsif nqp::istype($_, RakuAST::Name::Part::Expression) {
nqp::push_s($canon-parts, $_.expr.DEPARSE);
nqp::push_s($canon-parts, '') if nqp::elems($!parts) == 1;
nqp::push_s($canon-parts, '(' ~ $_.expr.DEPARSE ~ ')');
}
else {
nqp::die('canonicalize NYI for non-simple name part ' ~ $_.HOW.name($_));
Expand Down
8 changes: 7 additions & 1 deletion src/core.c/RakuAST/Raku.pm6
Expand Up @@ -1290,7 +1290,13 @@ augment class RakuAST::Name::Part {
}

multi method raku(RakuAST::Name::Part::Expression:D: --> Str:D) {
self.^name ~ '.new(' ~ self.expr.raku ~ ')';
my str @parts = self.^name ~ '.new(';
RakuAST::Node::indent();
@parts.push: $*INDENT ~ self.expr.raku;
RakuAST::Node::dedent();
@parts.push: $*INDENT ~ ")";

@parts.join("\n")
}

multi method raku(RakuAST::Name::Part::Simple:D: --> Str:D) {
Expand Down

0 comments on commit b685e67

Please sign in to comment.