Skip Menu |
Report information
Id: 130793
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: bri [at] abrij.org
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: explicit .resume on Broken promise exception "not resumable", implicit fine
Download (untitled) / with headers
text/plain 762b
In abf6caf0 the ability to explicitly .resume an exception caused by awaiting a broken promise... broke. However, implicitly resuming after handling the exception still works fine. $ perl6 -e 'my $p = Promise.new; my $b = 0; my $w = start { await($p); CATCH { default { $b = 1; .resume } } }; $p.break; await($w); $b.say' Tried to get the result of a broken Promise in block <unit> at -e line 1 Original exception: This exception is not resumable in block at -e line 1 in block at -e line 1 bri@atlas:~/git/perl6-xcb$ perl6 -e 'my $p = Promise.new; my $b = 0; my $w = start { await($p); CATCH { default { $b = 1; } } }; $p.break; await($w); $b.say' 1 various bot output links at: https://irclog.perlgeek.de/perl6/2017-02-16#i_14111000
To: perl6-compiler [...] perl.org
From: Timo Paulssen <timo [...] wakelift.de>
Subject: Re: [perl #130793] explicit .resume on Broken promise exception "not resumable", implicit fine
Date: Thu, 16 Feb 2017 12:06:20 +0100
Download (untitled) / with headers
text/plain 2.4k
You might be confusing resuming an exception with leaving the CATCH block with the exception marked as "handled". When you leave the block after having matched the exception successfully with a default or when block (or whatever else), the exception is marked as handled, which means it won't get re-thrown at the end of the CATCH block. When you call .resume on an exception, it will continue running the code in the place where the exception was thrown. Here's two code examples, one with resume, one without (exceptions thrown with "die" are resumable.) perl6 -e 'sub throws() { die "oh no"; say "inside &throws, after dying"; }; sub catches { say "before"; throws; say "after"; CATCH { default { say "caught"; .resume; say "resumed" } }; say "after CATCH" }; catches' before caught inside &throws, after dying after after CATCH perl6 -e 'sub throws() { die "oh no"; say "inside &throws, after dying"; }; sub catches { say "before"; throws; say "after"; CATCH { default { say "caught"; say "not resumed" } }; say "after CATCH" }; catches' before caught not resumed Note also that the CATCH block is something "attached to" the block that contains it, and as such leaving the CATCH block with success will also leave the containing block (that's why it says "not resumed", but not "after CATCH" in the second example) I'm thinking this is NOTABUG and can be closed, though perhaps the docs aren't sufficient about exception handling? On 16/02/17 05:02, Brian S. Julin (via RT) wrote: Show quoted text
> # New Ticket Created by "Brian S. Julin" > # Please include the string: [perl #130793] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=130793 > > > > > In abf6caf0 the ability to explicitly .resume an exception caused by awaiting a broken > promise... broke. However, implicitly resuming after handling the exception still works fine. > > $ perl6 -e 'my $p = Promise.new; my $b = 0; my $w = start { await($p); CATCH { default { $b = 1; .resume } } }; $p.break; await($w); $b.say' Tried to get the result of a broken Promise > in block <unit> at -e line 1 > > Original exception: > This exception is not resumable > in block at -e line 1 > in block at -e line 1 > > bri@atlas:~/git/perl6-xcb$ perl6 -e 'my $p = Promise.new; my $b = 0; my $w = start { await($p); CATCH { default { $b = 1; } } }; $p.break; await($w); $b.say' > 1 > > various bot output links at: > > https://irclog.perlgeek.de/perl6/2017-02-16#i_14111000
Download (untitled) / with headers
text/plain 433b
On Thu, 16 Feb 2017 03:07:23 -0800, timo wrote: Show quoted text
> You might be confusing resuming an exception with leaving the CATCH > block with the exception marked as "handled".
OK. But that just means this exception type has suddenly become unresumable (see the bisect logs), when it used to be resumable. So the question is, should awaiting a Promise that breaks be something you can resume from, or was this behavioral change intentional?


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org