Skip to content
Permalink
Browse files

Fix for #2739

Two methods on Rakudo::Internals are added: MAYBE-GIST and MAYBE-STR to
be used where .gist and .Str are needed correspondigly but where a
generic or other non-Mu type could appear.

X::Parameter::Default::TypeCheck is making use of MAYBE-GIST. Also
encolsed $!expected.^name call in curly braces to ensure proper calling
of the .name method.
  • Loading branch information...
vrurg committed Mar 5, 2019
1 parent a8cd286 commit 8f59177afb1ad802c7d8ffcd0b199985fc2827b1
Showing with 10 additions and 4 deletions.
  1. +3 −3 src/core/Exception.pm6
  2. +7 −1 src/core/Rakudo/Internals.pm6
@@ -409,8 +409,8 @@ do {
if $e.is-compile-time || $e.backtrace && $e.backtrace.is-runtime {
$err.say($e.gist);
if $v and !$e.gist.ends-with($v.Str) {
$err.say("Actually thrown at:");
$err.say($v.Str);
$err.say("Actually thrown at:");
$err.say($v.Str);
}
}
elsif Rakudo::Internals.VERBATIM-EXCEPTION(0) {
@@ -1194,7 +1194,7 @@ my class X::Parameter::Default::TypeCheck does X::Comp {
has $.got is default(Nil);
has $.expected is default(Nil);
method message() {
"Default value '$.got.gist()' will never bind to a parameter of type $.expected.^name()"
"Default value '{Rakudo::Internals.MAYBE-GIST: $!got}' will never bind to a parameter of type {$!expected.^name}"
}
}

@@ -661,8 +661,14 @@ implementation detail and has no serviceable parts inside"
}
}

method MAYBE-STR(Mu \thing) {
nqp::can(nqp::decont(thing), 'Str') ?? thing.Str !! thing.^name;
}
method MAYBE-GIST(Mu \thing) {
nqp::can(nqp::decont(thing), 'gist') ?? thing.gist !! thing.^name;
}
method SHORT-GIST(Mu \thing) {
my str $gist = nqp::can(thing, 'gist') ?? thing.gist !! thing.^name;
my str $gist = self.MAYBE-GIST(thing);
nqp::if(
nqp::isgt_i(nqp::chars($gist), 23),
nqp::concat(nqp::substr($gist, 0, 20), '...'),

0 comments on commit 8f59177

Please sign in to comment.
You can’t perform that action at this time.