From 1fbb8b4053cba722567b1e376c4a3f655b55e42b Mon Sep 17 00:00:00 2001 From: Pepe Schwarz Date: Tue, 5 Jul 2016 10:32:27 +0000 Subject: [PATCH] Fix a few CX creation cases and don't give a null to p6box_s --- src/core/Exception.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core/Exception.pm b/src/core/Exception.pm index f255b4e8a0d..8be5553f558 100644 --- a/src/core/Exception.pm +++ b/src/core/Exception.pm @@ -236,6 +236,9 @@ my class CX::Succeed does X::Control { my class CX::Proceed does X::Control { method message() { "" } } +my class CX::Return does X::Control { + method message() { "" } +} sub EXCEPTION(|) { my Mu $vm_ex := nqp::shift(nqp::p6argvmarray()); @@ -246,13 +249,13 @@ sub EXCEPTION(|) { } else { my int $type = nqp::getextype($vm_ex); my $ex; - if $type == nqp::const::CONTROL_NEXT { + if $type +& nqp::const::CONTROL_NEXT { $ex := CX::Next.new(); } - elsif $type == nqp::const::CONTROL_REDO { + elsif $type +& nqp::const::CONTROL_REDO { $ex := CX::Redo.new(); } - elsif $type == nqp::const::CONTROL_LAST { + elsif $type +& nqp::const::CONTROL_LAST { $ex := CX::Last.new(); } elsif $type == nqp::const::CONTROL_TAKE { @@ -269,6 +272,9 @@ sub EXCEPTION(|) { elsif $type == nqp::const::CONTROL_PROCEED { $ex := CX::Proceed.new(); } + elsif $type == nqp::const::CONTROL_RETURN { + $ex := CX::Return.new(); + } elsif !nqp::isnull_s(nqp::getmessage($vm_ex)) && nqp::p6box_s(nqp::getmessage($vm_ex)) ~~ /"Method '" (.*?) "' not found for invocant of class '" (.+)\'$/ { $ex := X::Method::NotFound.new( @@ -278,7 +284,7 @@ sub EXCEPTION(|) { } else { $ex := nqp::create(X::AdHoc); - nqp::bindattr($ex, X::AdHoc, '$!payload', nqp::p6box_s(nqp::getmessage($vm_ex))); + nqp::bindattr($ex, X::AdHoc, '$!payload', nqp::p6box_s(nqp::getmessage($vm_ex) // 'unknown exception')); } nqp::bindattr($ex, Exception, '$!ex', $vm_ex); $ex;