From 9ca1198650b5809229055d7a2c86943d846e1d34 Mon Sep 17 00:00:00 2001 From: ab5tract Date: Mon, 30 Oct 2023 10:32:30 +0100 Subject: [PATCH] RakuAST: Re-generate meta-objects on name or signature change The previous behavior was only inheriting a blank signature when defining a custom operator. This change allows the following code to work: multi sub infix:($x, $y) { "$x|$y" }; (* quack 5).(3).say --- src/Raku/ast/code.rakumod | 2 ++ src/Raku/ast/meta.rakumod | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/Raku/ast/code.rakumod b/src/Raku/ast/code.rakumod index d0bd07f23da..10877044cb1 100644 --- a/src/Raku/ast/code.rakumod +++ b/src/Raku/ast/code.rakumod @@ -1390,11 +1390,13 @@ class RakuAST::Routine method replace-name(RakuAST::Name $new-name) { nqp::bindattr(self, RakuAST::Routine, '$!name', $new-name); + self.IMPL-RESET-CACHED-META-OBJECT; Nil } method replace-signature(RakuAST::Signature $new-signature) { nqp::bindattr(self, RakuAST::Routine, '$!signature', $new-signature); + self.IMPL-RESET-CACHED-META-OBJECT; Nil } diff --git a/src/Raku/ast/meta.rakumod b/src/Raku/ast/meta.rakumod index 7e5ab2fbb5c..f658f4194e8 100644 --- a/src/Raku/ast/meta.rakumod +++ b/src/Raku/ast/meta.rakumod @@ -24,6 +24,10 @@ class RakuAST::Meta method compile-time-value() { self.meta-object } + + method IMPL-RESET-CACHED-META-OBJECT() { + nqp::bindattr(self, RakuAST::Meta, '$!meta-object-produced', False); + } } # Anything doing RakuAST::StubbyMeta is not only capable of producing a