Skip to content

Commit

Permalink
Allow Mu.say/put/note handling objects with NQP methods
Browse files Browse the repository at this point in the history
The Match object has a "print" method that lives in NQP.  Calling .say
(and .put and .note) on a Match object was broken with 88d9822 .
This commit fixes that.
  • Loading branch information
lizmat committed Jul 1, 2020
1 parent 0a86798 commit 9f546ef
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/core.c/Mu.pm6
Expand Up @@ -684,8 +684,9 @@ Perhaps it can be found at https://docs.raku.org/type/$name"
# Handle the typical "foo.say"
multi method say() {

# no own print method, so use $*OUT.print
if nqp::eqaddr(self.^find_method("print").package,Mu) {
my $method := self.^find_method("print");
if nqp::not_i(nqp::istype($method,Mu)) # an NQP routine
|| nqp::eqaddr($method.package,Mu) { # no own print method, use $*OUT
$_ := $*OUT;
.print(nqp::concat(self.gist,.nl-out))
}
Expand All @@ -712,8 +713,9 @@ Perhaps it can be found at https://docs.raku.org/type/$name"
# Handle the typical "foo.put"
multi method put() {

# no own print method, so use $*OUT.print
if nqp::eqaddr(self.^find_method("print").package,Mu) {
my $method := self.^find_method("print");
if nqp::not_i(nqp::istype($method,Mu)) # an NQP routine
|| nqp::eqaddr($method.package,Mu) { # no own print method, use $*OUT
$_ := $*OUT;
.print(nqp::concat(self.Str,.nl-out))
}
Expand All @@ -740,8 +742,9 @@ Perhaps it can be found at https://docs.raku.org/type/$name"
# Handle the typical "foo.note"
multi method note() {

# no own print method, so use $*ERR.print
if nqp::eqaddr(self.^find_method("print").package,Mu) {
my $method := self.^find_method("print");
if nqp::not_i(nqp::istype($method,Mu)) # an NQP routine
|| nqp::eqaddr($method.package,Mu) { # no own print method, use $*ERR
$_ := $*ERR;
.print(nqp::concat(self.gist,.nl-out))
}
Expand Down

0 comments on commit 9f546ef

Please sign in to comment.