Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package perl-Syntax-Keyword-Try for openSUSE:Factory checked in at 2021-08-31 19:55:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Syntax-Keyword-Try (Old) and /work/SRC/openSUSE:Factory/.perl-Syntax-Keyword-Try.new.1899 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Syntax-Keyword-Try" Tue Aug 31 19:55:41 2021 rev:12 rq:915220 version:0.25 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Syntax-Keyword-Try/perl-Syntax-Keyword-Try.changes 2021-05-12 19:33:30.222732858 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Syntax-Keyword-Try.new.1899/perl-Syntax-Keyword-Try.changes 2021-08-31 19:56:35.254029696 +0200 @@ -1,0 +2,13 @@ +Wed Jun 2 03:07:19 UTC 2021 - Tina M??ller <timueller+p...@suse.de> + +- updated to 0.25 + see /usr/share/doc/packages/perl-Syntax-Keyword-Try/Changes + + 0.25 2021-06-01 + [CHANGES] + * Rewrite parsing logic to use XS::Parse::Keyword 0.06 + * Removed the new-deprecated `try do { ... }` experimental syntax + * Updated docs now that 5.34 is officially released, including + `use feature 'try'`. + +------------------------------------------------------------------- Old: ---- Syntax-Keyword-Try-0.24.tar.gz New: ---- Syntax-Keyword-Try-0.25.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Syntax-Keyword-Try.spec ++++++ --- /var/tmp/diff_new_pack.pTWaq2/_old 2021-08-31 19:56:35.678030283 +0200 +++ /var/tmp/diff_new_pack.pTWaq2/_new 2021-08-31 19:56:35.682030288 +0200 @@ -18,7 +18,7 @@ %define cpan_name Syntax-Keyword-Try Name: perl-Syntax-Keyword-Try -Version: 0.24 +Version: 0.25 Release: 0 Summary: C<try/catch/finally> syntax for perl License: Artistic-1.0 OR GPL-1.0-or-later @@ -30,6 +30,9 @@ BuildRequires: perl(ExtUtils::CBuilder) BuildRequires: perl(Module::Build) >= 0.400400 BuildRequires: perl(Test::More) >= 0.88 +BuildRequires: perl(XS::Parse::Keyword) >= 0.06 +BuildRequires: perl(XS::Parse::Keyword::Builder) >= 0.06 +Requires: perl(XS::Parse::Keyword) >= 0.06 %{perl_requires} %description @@ -44,10 +47,9 @@ for perl code. Syntax similar to this module has now been added to core perl, starting at -development version 5.33.7, and is expected to become generally available -when perl 5.34 is released. If you are writing new code, it is suggested -that you instead use the Feature::Compat::Try module instead, as that will -enable the core feature on those supported perl versions, falling back to +version 5.34.0. If you are writing new code, it is suggested that you +instead use the Feature::Compat::Try module instead, as that will enable +the core feature on those supported perl versions, falling back to 'Syntax::Keyword::Try' on older perls. %prep ++++++ Syntax-Keyword-Try-0.24.tar.gz -> Syntax-Keyword-Try-0.25.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/Build.PL new/Syntax-Keyword-Try-0.25/Build.PL --- old/Syntax-Keyword-Try-0.24/Build.PL 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/Build.PL 2021-06-01 22:49:17.000000000 +0200 @@ -3,6 +3,7 @@ use warnings; use Module::Build; +use XS::Parse::Keyword::Builder; my $build = Module::Build->new( module_name => "Syntax::Keyword::Try", @@ -11,9 +12,11 @@ }, configure_requires => { 'Module::Build' => '0.4004', # test_requires + 'XS::Parse::Keyword::Builder' => '0.06', }, requires => { 'perl' => '5.014', # pluggable keywords, XOP + 'XS::Parse::Keyword' => '0.06', }, license => 'perl', create_license => 1, @@ -27,4 +30,6 @@ extra_compiler_flags => [qw( -Ihax )], ); +XS::Parse::Keyword::Builder->extend_module_build( $build ); + $build->create_build_script; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/Changes new/Syntax-Keyword-Try-0.25/Changes --- old/Syntax-Keyword-Try-0.24/Changes 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/Changes 2021-06-01 22:49:17.000000000 +0200 @@ -1,5 +1,12 @@ Revision history for Syntax-Keyword-Try +0.25 2021-06-01 + [CHANGES] + * Rewrite parsing logic to use XS::Parse::Keyword 0.06 + * Removed the new-deprecated `try do { ... }` experimental syntax + * Updated docs now that 5.34 is officially released, including + `use feature 'try'`. + 0.24 2021-05-10 [CHANGES] * Deprecate the `try do { ... }` (experimental) syntax now that diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/MANIFEST new/Syntax-Keyword-Try-0.25/MANIFEST --- old/Syntax-Keyword-Try-0.24/MANIFEST 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/MANIFEST 2021-06-01 22:49:17.000000000 +0200 @@ -1,9 +1,7 @@ Build.PL Changes -hax/lexer-additions.c.inc hax/perl-additions.c.inc hax/perl-backcompat.c.inc -hax/wrap_keyword_plugin.c.inc lib/Syntax/Keyword/Try.pm lib/Syntax/Keyword/Try.xs lib/Syntax/Keyword/Try/Deparse.pm @@ -24,8 +22,6 @@ t/14try-localises.t t/15context.t t/16final-expr.t -t/20try-do.t -t/21try-do-finally.t t/30compat.t t/70deparse.t t/80await+SKT.t diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/META.json new/Syntax-Keyword-Try-0.25/META.json --- old/Syntax-Keyword-Try-0.24/META.json 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/META.json 2021-06-01 22:49:17.000000000 +0200 @@ -21,11 +21,13 @@ }, "configure" : { "requires" : { - "Module::Build" : "0.4004" + "Module::Build" : "0.4004", + "XS::Parse::Keyword::Builder" : "0.06" } }, "runtime" : { "requires" : { + "XS::Parse::Keyword" : "0.06", "perl" : "5.014" } }, @@ -38,11 +40,11 @@ "provides" : { "Syntax::Keyword::Try" : { "file" : "lib/Syntax/Keyword/Try.pm", - "version" : "0.24" + "version" : "0.25" }, "Syntax::Keyword::Try::Deparse" : { "file" : "lib/Syntax/Keyword/Try/Deparse.pm", - "version" : "0.24" + "version" : "0.25" } }, "release_status" : "stable", @@ -52,6 +54,6 @@ ], "x_IRC" : "irc://irc.perl.org/#io-async" }, - "version" : "0.24", + "version" : "0.25", "x_serialization_backend" : "JSON::PP version 4.05" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/META.yml new/Syntax-Keyword-Try-0.25/META.yml --- old/Syntax-Keyword-Try-0.24/META.yml 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/META.yml 2021-06-01 22:49:17.000000000 +0200 @@ -7,6 +7,7 @@ Test::More: '0.88' configure_requires: Module::Build: '0.4004' + XS::Parse::Keyword::Builder: '0.06' dynamic_config: 1 generated_by: 'Module::Build version 0.4231, CPAN::Meta::Converter version 2.150010' license: perl @@ -17,14 +18,15 @@ provides: Syntax::Keyword::Try: file: lib/Syntax/Keyword/Try.pm - version: '0.24' + version: '0.25' Syntax::Keyword::Try::Deparse: file: lib/Syntax/Keyword/Try/Deparse.pm - version: '0.24' + version: '0.25' requires: + XS::Parse::Keyword: '0.06' perl: '5.014' resources: IRC: irc://irc.perl.org/#io-async license: http://dev.perl.org/licenses/ -version: '0.24' +version: '0.25' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/README new/Syntax-Keyword-Try-0.25/README --- old/Syntax-Keyword-Try-0.24/README 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/README 2021-06-01 22:49:17.000000000 +0200 @@ -30,11 +30,10 @@ and behaviours for perl code. Syntax similar to this module has now been added to core perl, starting - at development version 5.33.7, and is expected to become generally - available when perl 5.34 is released. If you are writing new code, it - is suggested that you instead use the Feature::Compat::Try module - instead, as that will enable the core feature on those supported perl - versions, falling back to Syntax::Keyword::Try on older perls. + at version 5.34.0. If you are writing new code, it is suggested that + you instead use the Feature::Compat::Try module instead, as that will + enable the core feature on those supported perl versions, falling back + to Syntax::Keyword::Try on older perls. Experimental Features @@ -50,8 +49,6 @@ use Syntax::Keyword::Try qw( try :experimental(typed) ); - use Syntax::Keyword::Try qw( try :experimental(try_value) ); # deprecated - use Syntax::Keyword::Try qw( try :experimental ); # all of the above Don't forget to import the main try symbol itself, to activate the @@ -220,51 +217,6 @@ with that feature instead, you should consider using Syntax::Keyword::Defer rather than using finally statements. -VALUE SEMANTICS - - Warning: the feature described in this section was experimental and - is now deprecated. This experiment has existed for a while, though - given that since version 0.22 the regular try syntax already behaves - fine inside a do block, there is no longer any reason for this - experimental feature to exist. It will print a deprecation warning, - and eventually will be removed in a later version. You should use do - { try ... } instead. - - Additionally, on perl versions 5.18 and later, it will produce a - warning in the experimental category. - - The syntax provided by this module may be used as a value-yielding - expression. Because this syntax is new, experimental, and somewhat - surprising, it must be specifically requested by name try_value: - - use Syntax::Keyword::Try qw( try try_value ); - - my $result = try do { ... } catch { ... }; - - Also, on Perl versions 5.24 and later: - - my $result = try do { ... } finally { ... }; - - my $result = try do { ... } catch { ... } finally { ... }; - - Specifically, note that the expression must be spelled as try do { ... - } so that the syntax is distinct from that used by control-flow - statements. The interposed do keyword reminds the reader, and instructs - the syntax parser, that this will be an expression, not a statement. It - is not necessary to similarly notate the catch or finally blocks. - - In this case, the syntax behaves syntactically like an expression, and - may appear anywhere a normal expression is allowed. It follows similar - semantics to the purely control-flow case; if the code in the try block - does not throw an exception, then the expression as a whole yields - whatever value the try expression did. If it fails, then the catch - block is executed and the expression yields its resulting value - instead. A finally block, if present, will be evaluated for - side-effects before the rest of the expression returns. - - Remember that, as in the control-flow case, the return keyword will - cause the entire containing function to return, not just the try block. - OTHER MODULES There are already quite a number of modules on CPAN that provide a @@ -279,9 +231,7 @@ * Syntax::Feature::Try In addition, core perl itself gained a try/catch syntax based on this - module at developemnt version 5.33.7, and should become generally - available when 5.34 is released. It will be available as use feature - 'try'. + module at version 5.34.0. It is available as use feature 'try'. They are compared here, by feature: @@ -337,10 +287,9 @@ Value Semantics Like Try and Syntax::Feature::Try, the syntax provided by this module - only works as a syntax-level statement and not an expression when the - experimental try_value feature described above has not been enabled. - You cannot assign from the result of a try block. A common workaround - is to wrap the try/catch statement inside a do block, where its final + only works as a syntax-level statement and not an expression. You + cannot assign from the result of a try block. A common workaround is to + wrap the try/catch statement inside a do block, where its final expression can be captured and used as a value. The same do block wrapping also works for the core feature 'try'. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/hax/lexer-additions.c.inc new/Syntax-Keyword-Try-0.25/hax/lexer-additions.c.inc --- old/Syntax-Keyword-Try-0.24/hax/lexer-additions.c.inc 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/hax/lexer-additions.c.inc 1970-01-01 01:00:00.000000000 +0100 @@ -1,298 +0,0 @@ -/* vi: set ft=c inde=: */ - -/* Perls before 5.18 lack isIDCONT_uni, but baring minor differences of weird - * Unicode characters, isALNUM_uni is close enough - */ -#ifndef isIDCONT_uni -#define isIDCONT_uni(c) isALNUM_uni(c) -#endif - -#define sv_cat_c(sv, c) MY_sv_cat_c(aTHX_ sv, c) -static void MY_sv_cat_c(pTHX_ SV *sv, U32 c) -{ - char ds[UTF8_MAXBYTES + 1], *d; - d = (char *)uvchr_to_utf8((U8 *)ds, c); - if (d - ds > 1) { - sv_utf8_upgrade(sv); - } - sv_catpvn(sv, ds, d - ds); -} - -#define lex_consume(s) MY_lex_consume(aTHX_ s) -static int MY_lex_consume(pTHX_ char *s) -{ - /* I want strprefix() */ - size_t i; - for(i = 0; s[i]; i++) { - if(s[i] != PL_parser->bufptr[i]) - return 0; - } - - lex_read_to(PL_parser->bufptr + i); - return i; -} - -enum { - LEX_IDENT_PACKAGENAME = (1<<0), -}; - -#define lex_scan_ident( ) MY_lex_scan_ident(aTHX_ 0) -#define lex_scan_packagename() MY_lex_scan_ident(aTHX_ LEX_IDENT_PACKAGENAME) -static SV *MY_lex_scan_ident(pTHX_ int flags) -{ - I32 c; - bool at_start = TRUE; - - char *ident = PL_parser->bufptr; - - while((c = lex_peek_unichar(0))) { - if(at_start ? isIDFIRST_uni(c) : isALNUM_uni(c)) - at_start = FALSE; - /* TODO: This sucks in the case of a false Foo:Bar match */ - else if((flags & LEX_IDENT_PACKAGENAME) && (c == ':')) { - lex_read_unichar(0); - if(lex_read_unichar(0) != ':') - croak("Expected colon to be followed by another in package name"); - } - else - break; - - lex_read_unichar(0); - } - - STRLEN len = PL_parser->bufptr - ident; - if(!len) - return NULL; - - SV *ret = newSVpvn(ident, len); - if(lex_bufutf8()) - SvUTF8_on(ret); - - return ret; -} - -#define lex_scan_attrval_into(name, val) MY_lex_scan_attrval_into(aTHX_ name, val) -static bool MY_lex_scan_attrval_into(pTHX_ SV *name, SV *val) -{ - /* TODO: really want lex_scan_ident_into() */ - SV *n = lex_scan_ident(); - if(!n) - return FALSE; - - sv_setsv(name, n); - SvREFCNT_dec(n); - - if(name != val) - SvPOK_off(val); - - /* Do not read space here as space is not allowed between NAME(ARGS) */ - - if(lex_peek_unichar(0) != '(') - return TRUE; - - lex_read_unichar(0); - if(name == val) - sv_cat_c(val, '('); - else - sv_setpvs(val, ""); - - int count = 1; - I32 c = lex_peek_unichar(0); - while(count && c != -1) { - if(c == '(') - count++; - if(c == ')') - count--; - if(c == '\\') { - /* The next char does not bump count even if it is ( or ); - * the \\ is still captured - */ - sv_cat_c(val, lex_read_unichar(0)); - c = lex_peek_unichar(0); - if(c == -1) - goto unterminated; - } - - /* Don't append final closing ')' on split name/val */ - if(count || (name == val)) - sv_cat_c(val, c); - lex_read_unichar(0); - - c = lex_peek_unichar(0); - } - - if(c == -1) - return FALSE; - - return TRUE; - -unterminated: - croak("Unterminated attribute parameter in attribute list"); -} - -#define lex_scan_attr() MY_lex_scan_attr(aTHX) -static SV *MY_lex_scan_attr(pTHX) -{ - SV *ret = newSV(0); - if(MY_lex_scan_attrval_into(aTHX_ ret, ret)) - return ret; - - SvREFCNT_dec(ret); - return NULL; -} - -#define lex_scan_attrs(compcv) MY_lex_scan_attrs(aTHX_ compcv) -static OP *MY_lex_scan_attrs(pTHX_ CV *compcv) -{ - /* Attributes are supplied to newATTRSUB() as an OP_LIST containing - * OP_CONSTs, one attribute in each as a plain SV. Note that we don't have - * to parse inside the contents of the parens; that is handled by the - * attribute handlers themselves - */ - OP *attrs = NULL; - SV *attr; - - lex_read_space(0); - while((attr = lex_scan_attr())) { - lex_read_space(0); - - if(compcv && strEQ(SvPV_nolen(attr), "lvalue")) { - CvLVALUE_on(compcv); - } - - if(!attrs) - attrs = newLISTOP(OP_LIST, 0, NULL, NULL); - - attrs = op_append_elem(OP_LIST, attrs, newSVOP(OP_CONST, 0, attr)); - - /* Accept additional colons to prefix additional attrs */ - if(lex_peek_unichar(0) == ':') { - lex_read_unichar(0); - lex_read_space(0); - } - } - - return attrs; -} - -#define lex_scan_lexvar() MY_lex_scan_lexvar(aTHX) -static SV *MY_lex_scan_lexvar(pTHX) -{ - int sigil = lex_peek_unichar(0); - switch(sigil) { - case '$': - case '@': - case '%': - lex_read_unichar(0); - break; - - default: - croak("Expected a lexical variable"); - } - - SV *ret = lex_scan_ident(); - if(!ret) - return NULL; - - /* prepend sigil - which we know to be a single byte */ - SvGROW(ret, SvCUR(ret) + 1); - Move(SvPVX(ret), SvPVX(ret) + 1, SvCUR(ret), char); - SvPVX(ret)[0] = sigil; - SvCUR(ret)++; - - SvPVX(ret)[SvCUR(ret)] = 0; - - return ret; -} - -#define lex_scan_parenthesized() MY_lex_scan_parenthesized(aTHX) -static SV *MY_lex_scan_parenthesized(pTHX) -{ - I32 c; - int parencount = 0; - SV *ret = newSVpvs(""); - if(lex_bufutf8()) - SvUTF8_on(ret); - - c = lex_peek_unichar(0); - - while(c != -1) { - sv_cat_c(ret, lex_read_unichar(0)); - - switch(c) { - case '(': parencount++; break; - case ')': parencount--; break; - } - if(!parencount) - break; - - c = lex_peek_unichar(0); - } - - if(SvCUR(ret)) - return ret; - - SvREFCNT_dec(ret); - return NULL; -} - -#define lex_scan_version(flags) MY_lex_scan_version(aTHX_ flags) -static SV *MY_lex_scan_version(pTHX_ int flags) -{ - I32 c; - SV *tmpsv = sv_2mortal(newSVpvs("")); - - /* scan_version() expects a version to end in linefeed, semicolon or - * openbrace; gets confused if other keywords are fine. We'll have to - * extract it first. - * https://rt.cpan.org/Ticket/Display.html?id=132903 - */ - - while((c = lex_peek_unichar(0))) { - /* Allow a single leading v before accepting only digits, dot, underscore */ - if((!SvCUR(tmpsv) && (c == 'v')) || strchr("0123456789._", c)) - sv_cat_c(tmpsv, lex_read_unichar(0)); - else - break; - } - - if(!SvCUR(tmpsv) && (flags & PARSE_OPTIONAL)) - return NULL; - - SV *ret = newSV(0); - scan_version(SvPVX(tmpsv), ret, FALSE); - - return ret; -} - -#define parse_lexvar() MY_parse_lexvar(aTHX) -static PADOFFSET MY_parse_lexvar(pTHX) -{ - /* TODO: Rewrite this in terms of using lex_scan_lexvar() - */ - char *lexname = PL_parser->bufptr; - - if(lex_read_unichar(0) != '$') - croak("Expected a lexical scalar at %s", lexname); - - if(!isIDFIRST_uni(lex_peek_unichar(0))) - croak("Expected a lexical scalar at %s", lexname); - lex_read_unichar(0); - while(isIDCONT_uni(lex_peek_unichar(0))) - lex_read_unichar(0); - - /* Forbid $_ */ - if(PL_parser->bufptr - lexname == 2 && lexname[1] == '_') - croak("Can't use global $_ in \"my\""); - - return pad_add_name_pvn(lexname, PL_parser->bufptr - lexname, 0, NULL, NULL); -} - -#define parse_scoped_block(flags) MY_parse_scoped_block(aTHX_ flags) -static OP *MY_parse_scoped_block(pTHX_ int flags) -{ - OP *ret; - I32 save_ix = block_start(TRUE); - ret = parse_block(flags); - return block_end(save_ix, ret); -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/hax/perl-additions.c.inc new/Syntax-Keyword-Try-0.25/hax/perl-additions.c.inc --- old/Syntax-Keyword-Try-0.24/hax/perl-additions.c.inc 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/hax/perl-additions.c.inc 2021-06-01 22:49:17.000000000 +0200 @@ -1,4 +1,4 @@ -/* vi: set ft=c inde=: */ +/* vi: set ft=c */ #ifndef av_count # define av_count(av) (AvFILL(av) + 1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/hax/wrap_keyword_plugin.c.inc new/Syntax-Keyword-Try-0.25/hax/wrap_keyword_plugin.c.inc --- old/Syntax-Keyword-Try-0.24/hax/wrap_keyword_plugin.c.inc 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/hax/wrap_keyword_plugin.c.inc 1970-01-01 01:00:00.000000000 +0100 @@ -1,28 +0,0 @@ -/* vi: set ft=c inde=: */ - -#ifndef OP_CHECK_MUTEX_LOCK /* < 5.15.8 */ -# define OP_CHECK_MUTEX_LOCK ((void)0) -# define OP_CHECK_MUTEX_UNLOCK ((void)0) -#endif - -#define wrap_keyword_plugin(func, var) S_wrap_keyword_plugin(aTHX_ func, var) - -static void S_wrap_keyword_plugin(pTHX_ Perl_keyword_plugin_t func, Perl_keyword_plugin_t *var) -{ - /* BOOT can potentially race with other threads (RT123547) */ - - /* Perl doesn't really provide us a nice mutex for doing this so this is the - * best we can find. See also - * https://rt.perl.org/Public/Bug/Display.html?id=132413 - */ - if(*var) - return; - - OP_CHECK_MUTEX_LOCK; - if(!*var) { - *var = PL_keyword_plugin; - PL_keyword_plugin = func; - } - - OP_CHECK_MUTEX_UNLOCK; -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/lib/Syntax/Keyword/Try/Deparse.pm new/Syntax-Keyword-Try-0.25/lib/Syntax/Keyword/Try/Deparse.pm --- old/Syntax-Keyword-Try-0.24/lib/Syntax/Keyword/Try/Deparse.pm 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/lib/Syntax/Keyword/Try/Deparse.pm 2021-06-01 22:49:17.000000000 +0200 @@ -3,7 +3,7 @@ # # (C) Paul Evans, 2021 -- leon...@leonerd.org.uk -package Syntax::Keyword::Try::Deparse 0.24; +package Syntax::Keyword::Try::Deparse 0.25; use v5.14; use warnings; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/lib/Syntax/Keyword/Try.pm new/Syntax-Keyword-Try-0.25/lib/Syntax/Keyword/Try.pm --- old/Syntax-Keyword-Try-0.24/lib/Syntax/Keyword/Try.pm 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/lib/Syntax/Keyword/Try.pm 2021-06-01 22:49:17.000000000 +0200 @@ -3,7 +3,7 @@ # # (C) Paul Evans, 2016-2021 -- leon...@leonerd.org.uk -package Syntax::Keyword::Try 0.24; +package Syntax::Keyword::Try 0.25; use v5.14; use warnings; @@ -45,10 +45,9 @@ code. Syntax similar to this module has now been added to core perl, starting at -development version 5.33.7, and is expected to become generally available when -perl 5.34 is released. If you are writing new code, it is suggested that you -instead use the L<Feature::Compat::Try> module instead, as that will enable -the core feature on those supported perl versions, falling back to +version 5.34.0. If you are writing new code, it is suggested that you instead +use the L<Feature::Compat::Try> module instead, as that will enable the core +feature on those supported perl versions, falling back to C<Syntax::Keyword::Try> on older perls. =head1 Experimental Features @@ -63,8 +62,6 @@ use Syntax::Keyword::Try qw( try :experimental(typed) ); - use Syntax::Keyword::Try qw( try :experimental(try_value) ); # deprecated - 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. @@ -234,56 +231,6 @@ should consider using L<Syntax::Keyword::Defer> rather than using C<finally> statements. -=head1 VALUE SEMANTICS - -=over 4 - -B<Warning:> the feature described in this section was experimental and is now -deprecated. This experiment has existed for a while, though given that since -version 0.22 the regular C<try> syntax already behaves fine inside a C<do> -block, there is no longer any reason for this experimental feature to exist. -It will print a deprecation warning, and eventually will be removed in a later -version. You should use C<do { try ... }> instead. - -Additionally, on I<perl> versions 5.18 and later, it will produce a warning -in the C<experimental> category. - -=back - -The syntax provided by this module may be used as a value-yielding expression. -Because this syntax is new, experimental, and somewhat surprising, it must be -specifically requested by name C<try_value>: - - use Syntax::Keyword::Try qw( try try_value ); - - my $result = try do { ... } catch { ... }; - -Also, on Perl versions 5.24 and later: - - my $result = try do { ... } finally { ... }; - - my $result = try do { ... } catch { ... } finally { ... }; - -Specifically, note that the expression must be spelled as C<try do { ... }> so -that the syntax is distinct from that used by control-flow statements. The -interposed C<do> keyword reminds the reader, and instructs the syntax parser, -that this will be an expression, not a statement. It is not necessary to -similarly notate the C<catch> or C<finally> blocks. - -In this case, the syntax behaves syntactically like an expression, and may -appear anywhere a normal expression is allowed. It follows similar semantics -to the purely control-flow case; if the code in the C<try> block does not -throw an exception, then the expression as a whole yields whatever value the -C<try> expression did. If it fails, then the C<catch> block is executed and -the expression yields its resulting value instead. A C<finally> block, if -present, will be evaluated for side-effects before the rest of the expression -returns. - -Remember that, as in the control-flow case, the C<return> keyword will cause -the entire containing function to return, not just the C<try> block. - -=cut - =head1 OTHER MODULES There are already quite a number of modules on CPAN that provide a @@ -310,8 +257,7 @@ =back In addition, core perl itself gained a C<try/catch> syntax based on this -module at developemnt version 5.33.7, and should become generally available -when 5.34 is released. It will be available as C<use feature 'try'>. +module at version 5.34.0. It is available as C<use feature 'try'>. They are compared here, by feature: @@ -366,11 +312,10 @@ =head2 Value Semantics Like L<Try> and L<Syntax::Feature::Try>, the syntax provided by this module -only works as a syntax-level statement and not an expression when the -experimental C<try_value> feature described above has not been enabled. You -cannot assign from the result of a C<try> block. A common workaround is to -wrap the C<try/catch> statement inside a C<do> block, where its final -expression can be captured and used as a value. +only works as a syntax-level statement and not an expression. You cannot +assign from the result of a C<try> block. A common workaround is to wrap +the C<try/catch> statement inside a C<do> block, where its final expression +can be captured and used as a value. The same C<do> block wrapping also works for the core C<feature 'try'>. @@ -422,7 +367,7 @@ $class->import_into( $caller, @_ ); } -my @EXPERIMENTAL = qw( typed try_value ); +my @EXPERIMENTAL = qw( typed ); sub import_into { @@ -433,7 +378,6 @@ my %syms = map { $_ => 1 } @syms; $^H{"Syntax::Keyword::Try/try"}++ if delete $syms{try}; - $^H{"Syntax::Keyword::Try/try_value"}++ if delete $syms{try_value}; # Largely for Feature::Compat::Try's benefit $^H{"Syntax::Keyword::Try/no_finally"}++ if delete $syms{"-no_finally"}; @@ -453,7 +397,10 @@ # 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)"}; + if( $syms{try_value} or $syms{":experimental(try_value)"} ) { + croak "The 'try_value' experimental feature is now removed\n" . + "Instead, you should use do { try ... } to yield a value from a try/catch statement"; + } croak "Unrecognised import symbols @{[ keys %syms ]}" if keys %syms; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/lib/Syntax/Keyword/Try.xs new/Syntax-Keyword-Try-0.25/lib/Syntax/Keyword/Try.xs --- old/Syntax-Keyword-Try-0.24/lib/Syntax/Keyword/Try.xs 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/lib/Syntax/Keyword/Try.xs 2021-06-01 22:49:17.000000000 +0200 @@ -7,6 +7,8 @@ #include "perl.h" #include "XSUB.h" +#include "XSParseKeyword.h" + #include "perl-backcompat.c.inc" #if HAVE_PERL_VERSION(5,32,0) @@ -23,12 +25,6 @@ typedef I32 array_ix_t; #endif /* <5.19.4 */ -#ifndef wrap_keyword_plugin -# include "wrap_keyword_plugin.c.inc" -#endif - -#include "lexer-additions.c.inc" - #include "perl-additions.c.inc" static OP *pp_entertrycatch(pTHX); @@ -415,66 +411,37 @@ } #endif -static int try_keyword(pTHX_ OP **op) +static int build_try(pTHX_ OP **out, XSParseKeywordPiece *args[], size_t nargs, void *hookdata) { - OP *try = NULL, *catch = NULL; - AV *condcatch = NULL; - CV *finally = NULL; - OP *ret = NULL; - bool is_value = FALSE; - HV *hints = GvHV(PL_hintgv); - - lex_read_space(0); + U32 argi = 0; - if(hints && hv_fetchs(hints, "Syntax::Keyword::Try/try_value", 0) && - lex_consume("do")) { - lex_read_space(0); - is_value = TRUE; - -#ifdef WARN_EXPERIMENTAL - 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 - - Perl_ck_warner(aTHX_ packWARN(WARN_DEPRECATED), - "'try do' syntax is deprecated and will be removed. Use do { try ... } instead"); - } + OP *try = args[argi++]->op; - if(lex_peek_unichar(0) != '{') - croak("Expected try to be followed by '{'"); - - try = parse_scoped_block(0); - lex_read_space(0); + OP *ret = NULL; + HV *hints = GvHV(PL_hintgv); bool require_var = hints && hv_fetchs(hints, "Syntax::Keyword::Try/require_var", 0); - while(lex_consume("catch")) { - OP *assignop = NULL, *condop = NULL; - OP *body; - I32 save_ix; + U32 ncatches = args[argi++]->i; - if(catch) - croak("Already have a default catch {} block"); - - save_ix = block_start(TRUE); - lex_read_space(0); + AV *condcatch = NULL; + OP *catch = NULL; + while(ncatches--) { + bool has_catchvar = args[argi++]->i; + PADOFFSET catchvar = has_catchvar ? args[argi++]->padix : 0; + int catchtype = has_catchvar ? args[argi++]->i : -1; - if(lex_consume("(")) { - PADOFFSET catchvar = 0; - bool warned = FALSE; + bool warned = FALSE; - lex_read_space(0); - catchvar = parse_lexvar(); + OP *condop = NULL; - /* my $var = $@ */ - assignop = newBINOP(OP_SASSIGN, 0, - newGVOP(OP_GVSV, 0, PL_errgv), newPADxVOP(OP_PADSV, catchvar, OPf_MOD, OPpLVAL_INTRO)); + switch(catchtype) { + case -1: /* no type */ + break; - lex_read_space(0); - if(lex_consume("isa")) { - OP *type = parse_termexpr(0); + case 0: /* isa */ + { + OP *type = args[argi++]->op; #ifdef HAVE_OP_ISA condop = newBINOP(OP_ISA, 0, newPADxVOP(OP_PADSV, catchvar, 0, 0), type); @@ -486,9 +453,12 @@ condop = newBINOP_CUSTOM(&pp_isa, 0, newPADxVOP(OP_PADSV, catchvar, 0, 0), type); #endif + break; } - else if(lex_consume("=~")) { - OP *regexp = parse_termexpr(0); + + case 1: /* =~ */ + { + OP *regexp = args[argi++]->op; if(regexp->op_type != OP_MATCH || cPMOPx(regexp)->op_first) croak("Expected a regexp match"); @@ -501,30 +471,36 @@ regexp->op_flags |= OPf_KIDS|OPf_STACKED; #endif condop = regexp; + break; } + default: + croak("TODO\n"); + } + #ifdef WARN_EXPERIMENTAL - if(condop && !warned && - (!hints || !hv_fetchs(hints, "Syntax::Keyword::Try/experimental(typed)", 0))) { - warned = true; - Perl_ck_warner(aTHX_ packWARN(WARN_EXPERIMENTAL), - "typed catch syntax is experimental and may be changed or removed without notice"); - } + if(condop && !warned && + (!hints || !hv_fetchs(hints, "Syntax::Keyword::Try/experimental(typed)", 0))) { + warned = true; + Perl_ck_warner(aTHX_ packWARN(WARN_EXPERIMENTAL), + "typed catch syntax is experimental and may be changed or removed without notice"); + } #endif - if(!lex_consume(")")) - croak("Expected close paren for catch (VAR)"); + OP *body = args[argi++]->op; - lex_read_space(0); - - intro_my(); - } - else if(require_var) { + if(require_var && !has_catchvar) croak("Expected (VAR) for catch"); - } - body = block_end(save_ix, parse_block(0)); - lex_read_space(0); + if(catch) + croak("Already have a default catch {} block"); + + OP *assignop = NULL; + if(catchvar) { + /* my $var = $@ */ + assignop = newBINOP(OP_SASSIGN, 0, + newGVOP(OP_GVSV, 0, PL_errgv), newPADxVOP(OP_PADSV, catchvar, OPf_MOD, OPpLVAL_INTRO)); + } if(condop) { if(!condcatch) @@ -536,8 +512,7 @@ } else if(assignop) { catch = op_prepend_elem(OP_LINESEQ, - assignop, - body); + assignop, body); } else catch = body; @@ -564,29 +539,11 @@ bool no_finally = hints && hv_fetchs(hints, "Syntax::Keyword::Try/no_finally", 0); - if(!no_finally && lex_consume("finally")) { - I32 floor_ix, save_ix; - OP *body; + U32 has_finally = args[argi++]->i; + CV *finally = has_finally ? args[argi++]->cv : NULL; -#if !HAVE_PERL_VERSION(5,24,0) - if(is_value) - croak("try do {} finally {} is not supported on this version of perl"); -#endif - - lex_read_space(0); - - floor_ix = start_subparse(FALSE, CVf_ANON); - SAVEFREESV(PL_compcv); - - save_ix = block_start(0); - body = parse_block(0); - SvREFCNT_inc(PL_compcv); - body = block_end(save_ix, body); - - finally = newATTRSUB(floor_ix, NULL, NULL, NULL, body); - - lex_read_space(0); - } + if(no_finally && finally) + croak("finally {} is not permitted here"); if(!catch && !finally) { op_free(try); @@ -598,7 +555,7 @@ ret = try; if(catch) { - ret = newENTERTRYCATCHOP(is_value ? OPf_WANT_SCALAR : 0, try, catch); + ret = newENTERTRYCATCHOP(0, try, catch); } /* If there's a finally, make @@ -614,30 +571,35 @@ newOP(OP_ENTER, 0), ret); - if(is_value) - ret->op_ppaddr = &pp_leave_keeping_stack; - - *op = ret; - return is_value ? KEYWORD_PLUGIN_EXPR : KEYWORD_PLUGIN_STMT; + *out = ret; + return KEYWORD_PLUGIN_STMT; } -static int (*next_keyword_plugin)(pTHX_ char *, STRLEN, OP **); - -static int my_keyword_plugin(pTHX_ char *kw, STRLEN kwlen, OP **op) -{ - HV *hints; - if(PL_parser && PL_parser->error_count) - return (*next_keyword_plugin)(aTHX_ kw, kwlen, op); - - if(!(hints = GvHV(PL_hintgv))) - return (*next_keyword_plugin)(aTHX_ kw, kwlen, op); +static struct XSParseKeywordHooks hooks_try = { + .permit_hintkey = "Syntax::Keyword::Try/try", - if(kwlen == 3 && strEQ(kw, "try") && - hv_fetchs(hints, "Syntax::Keyword::Try/try", 0)) - return try_keyword(aTHX_ op); - - return (*next_keyword_plugin)(aTHX_ kw, kwlen, op); -} + .pieces = (const struct XSParseKeywordPieceType []){ + XPK_BLOCK, + XPK_REPEATED( + XPK_LITERAL("catch"), + XPK_PREFIXED_BLOCK( + /* optionally ($var), ($var isa Type) or ($var =~ m/.../) */ + XPK_PARENSCOPE_OPT( + XPK_LEXVAR_MY(XPK_LEXVAR_SCALAR), + XPK_CHOICE( + XPK_SEQUENCE(XPK_LITERAL("isa"), XPK_TERMEXPR), + XPK_SEQUENCE(XPK_LITERAL("=~"), XPK_TERMEXPR) + ) + ) + ) + ), + XPK_OPTIONAL( + XPK_LITERAL("finally"), XPK_ANONSUB + ), + {0}, + }, + .build = &build_try, +}; MODULE = Syntax::Keyword::Try PACKAGE = Syntax::Keyword::Try @@ -661,4 +623,6 @@ Perl_custom_op_register(aTHX_ &pp_isa, &xop_isa); #endif - wrap_keyword_plugin(&my_keyword_plugin, &next_keyword_plugin); + boot_xs_parse_keyword(0.06); + + register_xs_parse_keyword("try", &hooks_try, NULL); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/t/20try-do.t new/Syntax-Keyword-Try-0.25/t/20try-do.t --- old/Syntax-Keyword-Try-0.24/t/20try-do.t 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/t/20try-do.t 1970-01-01 01:00:00.000000000 +0100 @@ -1,88 +0,0 @@ -#!/usr/bin/perl - -use v5.14; -use warnings; - -use Test::More; - -use constant HAVE_WARN_EXPERIMENTAL => $] >= 5.018; - -no if HAVE_WARN_EXPERIMENTAL, warnings => 'experimental'; -use Syntax::Keyword::Try qw( try try_value ); - -no warnings 'deprecated'; - -# try do { } yields result -{ - is( try do { "result" } catch ($e) {}, - "result", - 'try do { } yields result' ); -} - -# try do { } failure returns catch -{ - is( try do { die "oops\n" } catch ($e) { "failure" }, - "failure", - 'try do { } yields catch result on failure' ); -} - -# stack discipline -{ - my @v = ( 1, [ 2, try do { 3 } catch ($e) {}, 4 ], 5 ); - is_deeply( \@v, [ 1, [ 2 .. 4 ], 5 ], - 'try do { } preserves stack discipline' ) or - diag "Got ", explain \@v; -} - -# list context -{ - my @v = try do { 1, 2, 3 } catch ($e) {}; - is_deeply( \@v, [ 1 .. 3 ], - 'try do can yield lists' ); -} - -# $@ localising -SKIP: { - # RT124366 - skip "perls before 5.24 fail to lexicalise \$@ properly (RT124366)", 1 unless $] >= 5.024; - - eval { die "oopsie" }; - - my $ret = try do { die "another failure" } catch ($e) {}; - like( $@, qr/^oopsie at /, '$@ after try do/catch' ); -} - -# Non-try do { ... } unaffected -{ - is( do { 1 + 2 }, 3, - 'Plain do { ... } unaffected' ); -} - -# try do syntax produces experimental and deprecated warnings -SKIP: { - use if HAVE_WARN_EXPERIMENTAL, warnings => 'experimental'; - skip "No 'experimental' warnings category", 1 unless HAVE_WARN_EXPERIMENTAL; - - use warnings 'deprecated'; - - my $warnings = ""; - local $SIG{__WARN__} = sub { $warnings .= join "", @_ }; - - eval "try do { 1 } catch (\$e) { 2 }" or die $@; - - like( $warnings, qr/^'try do' syntax is experimental/, - 'try do syntax produces experimental warnings' ); - like( $warnings, qr/^'try do' syntax is deprecated /m, - 'try do syntax produces deprecated warnings' ); - - # warning can be disabled - use Syntax::Keyword::Try qw( :experimental(try_value) ); - no warnings 'deprecated'; - - $warnings = ""; - - eval "try do { 3 } catch (\$e) { 4 }" or die $@; - is( $warnings, "", 'no warnings when :experimental(try_value) is enabled' ); -} - -done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/t/21try-do-finally.t new/Syntax-Keyword-Try-0.25/t/21try-do-finally.t --- old/Syntax-Keyword-Try-0.24/t/21try-do-finally.t 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/t/21try-do-finally.t 1970-01-01 01:00:00.000000000 +0100 @@ -1,39 +0,0 @@ -#!/usr/bin/perl - -use v5.14; -use warnings; - -use Test::More; -BEGIN { - # Before 5.24 this code won't even compile - plan skip_all => "try do { } finally { } is not supported before perl 5.24" if $] < 5.024; -} - -use constant HAVE_WARN_EXPERIMENTAL => $] >= 5.018; - -no if HAVE_WARN_EXPERIMENTAL, warnings => 'experimental'; -use Syntax::Keyword::Try qw( try try_value ); - -no warnings 'deprecated'; - -# try do { } finally { } -{ - my $x; - my $result = try do { $x .= 1; "result" } - finally { $x .= 2 }, $x .= 3; - - is( $result, "result", 'try do { } finally yields result' ); - is( $x, "123", 'try do {} finally has finally side-effect' ); -} - -# try do { } catch { } finally { } -{ - my $x; - my $result = try do { $x .= 4; die "oops" } - catch ($e) { $x .= 5; "failure" } - finally { $x .= 6 }; - is( $result, "failure", 'try do {} catch finally catches exception' ); - is( $x, "456", 'try do {} catch finally has finally side-effect' ); -} - -done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Syntax-Keyword-Try-0.24/t/30compat.t new/Syntax-Keyword-Try-0.25/t/30compat.t --- old/Syntax-Keyword-Try-0.24/t/30compat.t 2021-05-10 15:39:16.000000000 +0200 +++ new/Syntax-Keyword-Try-0.25/t/30compat.t 2021-06-01 22:49:17.000000000 +0200 @@ -16,7 +16,7 @@ finally { 456 } EOPERL 'try/finally is forbidden' ); - like( $@, qr/^Expected try \{\} to be followed by catch \{\} / ); + like( $@, qr/^finally \{\} is not permitted here / ); } # require var