Skip Menu |

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

Report information
The Basics
Id: 133616
Status: open
Priority: 0/
Queue: Syntax-Keyword-Try

People
Owner: Nobody in particular
Requestors: jawala.birdi [...] gmail.com
Cc:
AdminCc:

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



Subject: Preserve wantarray ?
Date: Tue, 27 Oct 2020 11:35:21 -0400
To: bug-Syntax-Keyword-Try [...] rt.cpan.org
From: Jawala <jawala.birdi [...] gmail.com>
Hello, Is it by design that Syntax::Keyword::Try does not appear to preserve wantarray, when returning within a try block ? Running v0.18, tested on Perl 5.20.2 and 5.30.0. $ "perl" -MSyntax::Keyword::Try -wE 'my @v = foo(); sub foo { say wantarray; try { say "caller wants array" if wantarray; } catch {;} };' 1 By comparison, both TryCatch and Try::Tiny work "as expected", although I don't know their internals : $ "perl" -MTryCatch -wE 'my @v = foo(); sub foo { say wantarray; try { say "caller wants array" if wantarray; } catch {;} };' 1 caller wants array $ "perl" -MTry::Tiny -wE 'my @v = foo(); sub foo { say wantarray; try { say "caller wants array" if wantarray; } catch {;} };' 1 caller wants array If it is not technically possible to make Syntax::Keyword::Try preserve wantarray, could you maybe update the documentation to explicitly note this behaviour ? Regards, Jawala
On Tue Oct 27 12:54:38 2020, jawala.birdi@gmail.com wrote: Show quoted text
> Hello, > > Is it by design that Syntax::Keyword::Try does not appear to preserve > wantarray, when returning within a try block ?
No. It comes as an annoying side-effect of the way context propagation works through the compiled opcodes. As already noted in https://rt.cpan.org/Ticket/Display.html?id=124229 Show quoted text
> If it is not technically possible to make Syntax::Keyword::Try preserve > wantarray, could you maybe update the documentation to explicitly note > this behaviour ?
It is almost certainly *possible* to implement this, but so far I haven't found a way to implement it. -- Paul Evans