Skip Menu |

This queue is for tickets about the Syntax-Keyword-Try CPAN distribution.

Report information
The Basics
Id: 122795
Status: resolved
Priority: 0/
Queue: Syntax-Keyword-Try

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.06
Fixed in: 0.07



Subject: try { return } does not work correctly inside `async sub` (F:AA + S:K:T)
A `return` statement inside a try/catch block (Syntax::Keyword::Try) fails: async sub with_trycatch_return { try { await $f1; return "result"; } catch {} } The future that `with_trycatch_return` is never completed even after $f1 is, so attempting to force it complains that it "is not yet complete and does not provide ->await". -- Paul Evans
Fixing this likely requires making sure that `pp_returnintry()` doesn't pop the outermost `CXt_EVAL` context frame that `async sub` uses to implement itself. How to do this is a more interesting question. Two thoughts come to mind: 1) Count the nested `try` blocks and get `pp_returnintry` to pop only that number. This requires a more complicated treewalker and a field on OP_RETURN ops we can annotate the count onto. 2) Identify the `CXt_EVAL` frames used by `try` blocks and have `pp_returnintry` only pop those frames. This requires an ability of `pp_returnintry` to be able to recognise such frames. I don't yet have a feel for which is easier. -- Paul Evans
On Sun Aug 13 13:24:46 2017, PEVANS wrote: Show quoted text
> 2) Identify the `CXt_EVAL` frames used by `try` blocks and have > `pp_returnintry` only pop those frames. > > This requires an ability of `pp_returnintry` to be able to recognise > such > frames.
A partial implementation of this method seems to be going in the right direction. By overriding the ->op_ppaddr of an OP_ENTERTRY that implements a try{} block we can identify those eval contexts from other ones, and ensure that pp_returnintry only skips those, and not other eval{} frames. -- Paul Evans
Now fixed by 0.07 -- Paul Evans