Skip to content

Instantly share code, notes, and snippets.

@usev6
Last active November 2, 2015 23:05
Show Gist options
  • Save usev6/bac193a8b7219490993c to your computer and use it in GitHub Desktop.
Save usev6/bac193a8b7219490993c to your computer and use it in GitHub Desktop.
Prevent "Method 'Int' not found for invocant of class 'Any'"
diff --git a/src/core/Failure.pm b/src/core/Failure.pm
index 70aa7be..4a7baff 100644
--- a/src/core/Failure.pm
+++ b/src/core/Failure.pm
@@ -56,7 +56,7 @@ my class Failure {
multi method Str(Failure:D:) { $!handled ?? $.mess !! self!throw(); }
multi method gist(Failure:D:) { $!handled ?? $.mess !! self!throw(); }
method mess (Failure:D:) {
- "(HANDLED) " x $!handled ~ self.exception.message ~ "\n" ~ self.backtrace;
+ "(HANDLED) " x ($!handled ?? $!handled !! 0) ~ self.exception.message ~ "\n" ~ self.backtrace;
}
method sink(Failure:D:) {
@usev6
Copy link
Author

usev6 commented Nov 2, 2015

Aha, just saw: 'method mess' is called from 'submethod DESTROY' and yes, $!handled is not True in that case.

On the other hand it's still not clear why we hit 'submethod DESTROY' at all.

@lizmat
Copy link

lizmat commented Nov 2, 2015

making $!handled a native int also seems to have done the trick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment