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