Skip to content

Commit

Permalink
RakuAST: Re-generate meta-objects on name or signature change
Browse files Browse the repository at this point in the history
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:<quack>($x, $y) { "$x|$y" }; (* quack 5).(3).say
  • Loading branch information
ab5tract authored and lizmat committed Oct 30, 2023
1 parent 4a5e018 commit 9ca1198
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Raku/ast/code.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 4 additions & 0 deletions src/Raku/ast/meta.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9ca1198

Please sign in to comment.