From dfd270380303e09e3ca3f43818f5dacb09d1a237 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 10 Jan 2023 21:55:54 +0100 Subject: [PATCH] RakuAST: keep a difference in the AST for stubs with and without args While technically correct, we don't want a plain ... to deparse to ... 'Stub code executed' So instead of adding default arguments to the AST, keep the default args ephemeral. --- src/Raku/ast/call.rakumod | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Raku/ast/call.rakumod b/src/Raku/ast/call.rakumod index 283293e510e..4346e6f5a51 100644 --- a/src/Raku/ast/call.rakumod +++ b/src/Raku/ast/call.rakumod @@ -614,13 +614,19 @@ class RakuAST::Stub is RakuAST::Call::Name { method new(RakuAST::ArgList :$args) { my $obj := nqp::create(self); nqp::bindattr($obj, RakuAST::Call::Name, '$!name', RakuAST::Name.from-identifier(self.IMPL-FUNC-NAME)); - unless $args && $args.has-args { - $args := RakuAST::ArgList.new: - RakuAST::StrLiteral.new('Stub code executed') - } nqp::bindattr($obj, RakuAST::Call, '$!args', $args); $obj } + + method args() { + my $args := nqp::getattr(self, RakuAST::Call, '$!args'); + if $args && $args.has-args { + $args + } + else { + RakuAST::ArgList.new: RakuAST::StrLiteral.new('Stub code executed') + } + } } # the ... stub