From 0550ae7632ac136e4d1fff04b0deffc4bb84371c Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Wed, 28 Jun 2023 17:29:46 +0200 Subject: [PATCH] RakuAST: fix deparsing of (foo,bar).baz It was being deparsed as foo,bar.baz which is *not* the same. --- src/core.c/RakuAST/Deparse.pm6 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core.c/RakuAST/Deparse.pm6 b/src/core.c/RakuAST/Deparse.pm6 index a4c069a349a..281e38833b7 100644 --- a/src/core.c/RakuAST/Deparse.pm6 +++ b/src/core.c/RakuAST/Deparse.pm6 @@ -533,8 +533,18 @@ class RakuAST::Deparse { } multi method deparse(RakuAST::ApplyPostfix:D $ast --> Str:D) { - ($ast.on-topic ?? "" !! self.deparse($ast.operand).chomp) - ~ self.deparse($ast.postfix) + my str $deparsed-postfix = self.deparse($ast.postfix); + if $ast.on-topic { + $deparsed-postfix + } + else { + my $operand := $ast.operand; + my str $deparsed-operand = self.deparse($operand); + + nqp::istype($operand,RakuAST::ApplyListInfix) + ?? '(' ~ $deparsed-operand ~ ')' ~ $deparsed-postfix + !! $deparsed-operand ~ $deparsed-postfix + } } multi method deparse(RakuAST::ApplyPrefix:D $ast --> Str:D) {