Skip Menu |

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

Report information
The Basics
Id: 133523
Status: patched
Priority: 0/
Queue: Syntax-Keyword-Try

People
Owner: Nobody in particular
Requestors: cpan [...] robv.de
Cc:
AdminCc:

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



Subject: :experimental(try_value)
Date: Tue, 13 Oct 2020 08:37:44 +0200
To: bug-Syntax-Keyword-Try [...] rt.cpan.org
From: Robert Vollmer <cpan [...] robv.de>
The :experimental import tag looks useful. Could it be added for "try_value" as well? I.e. it would be great if these two statements would make the "try do {}" syntax available without warning: use Syntax::Keyword::Try qw( try :experimental(try_value) ); use Syntax::Keyword::Try qw( try :experimental );
On Tue Oct 13 02:38:14 2020, cpan@robv.de wrote: Show quoted text
> The :experimental import tag looks useful. Could it be added for > "try_value" as well? I.e. it would be great if these two statements would > make the "try do {}" syntax available without warning: > > use Syntax::Keyword::Try qw( try :experimental(try_value) ); > use Syntax::Keyword::Try qw( try :experimental );
Yes; sounds like a good idea. Patch attached. -- Paul Evans
Subject: rt133523.patch
=== modified file 'lib/Syntax/Keyword/Try.pm' --- old/lib/Syntax/Keyword/Try.pm 2020-08-01 16:17:55 +0000 +++ new/lib/Syntax/Keyword/Try.pm 2020-11-23 20:35:16 +0000 @@ -56,6 +56,8 @@ use Syntax::Keyword::Try qw( try :experimental(typed) ); + use Syntax::Keyword::Try qw( try :experimental(try_value) ); + use Syntax::Keyword::Try qw( try :experimental ); # all of the above Don't forget to import the main C<try> symbol itself, to activate the syntax. @@ -375,7 +377,7 @@ $class->import_into( $caller, @_ ); } -my @EXPERIMENTAL = qw( typed ); +my @EXPERIMENTAL = qw( typed try_value ); sub import_into { @@ -404,6 +406,8 @@ # Ignore requests for these, as they come automatically with `try` delete @syms{qw( catch finally )}; + $^H{"Syntax::Keyword::Try/try_value"}++ if $^H{"Syntax::Keyword::Try/experimental(try_value)"}; + croak "Unrecognised import symbols @{[ keys %syms ]}" if keys %syms; } === modified file 'lib/Syntax/Keyword/Try.xs' --- old/lib/Syntax/Keyword/Try.xs 2020-11-23 16:30:01 +0000 +++ new/lib/Syntax/Keyword/Try.xs 2020-11-23 20:31:00 +0000 @@ -430,8 +430,10 @@ is_value = TRUE; #ifdef WARN_EXPERIMENTAL - Perl_ck_warner(aTHX_ packWARN(WARN_EXPERIMENTAL), - "'try do' syntax is experimental and may be changed or removed without notice"); + if(!hints || !hv_fetchs(hints, "Syntax::Keyword::Try/experimental(try_value)", 0)) { + Perl_ck_warner(aTHX_ packWARN(WARN_EXPERIMENTAL), + "'try do' syntax is experimental and may be changed or removed without notice"); + } #endif } === modified file 't/20try-do.t' --- old/t/20try-do.t 2020-07-07 12:20:10 +0000 +++ new/t/20try-do.t 2020-11-23 20:32:24 +0000 @@ -71,6 +71,13 @@ like( $warnings, qr/^'try do' syntax is experimental/, 'try do syntax produces experimental warnings' ); + + # warning can be disabled + use Syntax::Keyword::Try qw( :experimental(try_value) ); + $warnings = ""; + + eval "try do { 3 } catch { 4 }" or die $@; + is( $warnings, "", 'no warnings when :experimental(try_value) is enabled' ); } done_testing;