Merge tag 'upstream/0.29' into openkylin/nile
Upstream version 0.29
This commit is contained in:
commit
7ef27b534a
|
@ -0,0 +1,4 @@
|
|||
root = true
|
||||
|
||||
[*.{pm,pl,t}]
|
||||
indent_size = 3
|
2
Build.PL
2
Build.PL
|
@ -8,7 +8,7 @@ use XS::Parse::Keyword::Builder;
|
|||
my $build = Module::Build->new(
|
||||
module_name => "Syntax::Keyword::Try",
|
||||
test_requires => {
|
||||
'Test::More' => '0.88', # done_testing
|
||||
'Test2::V0' => 0,
|
||||
},
|
||||
configure_requires => {
|
||||
'Module::Build' => '0.4004', # test_requires
|
||||
|
|
13
Changes
13
Changes
|
@ -1,5 +1,18 @@
|
|||
Revision history for Syntax-Keyword-Try
|
||||
|
||||
0.29 2023-07-13
|
||||
[CHANGES]
|
||||
* Updates to compile cleanly on perl v5.38
|
||||
* Remember to implement `no Syntax::Keyword::Try` to disable the
|
||||
syntax
|
||||
* Swap all the unit tests to `Test2::V0`
|
||||
|
||||
0.28 2022-12-08
|
||||
[CHANGES]
|
||||
* Account for the new structure of ->cop_warnings in perl v5.37.6
|
||||
* Updated to latest hax/ support files; accounting for newPADxVOP in
|
||||
latest bleadperl
|
||||
|
||||
0.27 2022-02-22
|
||||
[CHANGES]
|
||||
* Updates to support Feature::Compat::Try 0.05 with new `finally {}`
|
||||
|
|
6
LICENSE
6
LICENSE
|
@ -1,4 +1,4 @@
|
|||
This software is copyright (c) 2022 by Paul Evans <leonerd@leonerd.org.uk>.
|
||||
This software is copyright (c) 2023 by Paul Evans <leonerd@leonerd.org.uk>.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
@ -12,7 +12,7 @@ b) the "Artistic License"
|
|||
|
||||
--- The GNU General Public License, Version 1, February 1989 ---
|
||||
|
||||
This software is Copyright (c) 2022 by Paul Evans <leonerd@leonerd.org.uk>.
|
||||
This software is Copyright (c) 2023 by Paul Evans <leonerd@leonerd.org.uk>.
|
||||
|
||||
This is free software, licensed under:
|
||||
|
||||
|
@ -272,7 +272,7 @@ That's all there is to it!
|
|||
|
||||
--- The Artistic License 1.0 ---
|
||||
|
||||
This software is Copyright (c) 2022 by Paul Evans <leonerd@leonerd.org.uk>.
|
||||
This software is Copyright (c) 2023 by Paul Evans <leonerd@leonerd.org.uk>.
|
||||
|
||||
This is free software, licensed under:
|
||||
|
||||
|
|
9
MANIFEST
9
MANIFEST
|
@ -1,3 +1,4 @@
|
|||
.editorconfig
|
||||
Build.PL
|
||||
Changes
|
||||
hax/newOP_CUSTOM.c.inc
|
||||
|
@ -8,7 +9,11 @@ hax/perl-backcompat.c.inc
|
|||
lib/Syntax/Keyword/Try.pm
|
||||
lib/Syntax/Keyword/Try.xs
|
||||
lib/Syntax/Keyword/Try/Deparse.pm
|
||||
LICENSE
|
||||
MANIFEST This list of files
|
||||
META.json
|
||||
META.yml
|
||||
README
|
||||
t/00use.t
|
||||
t/01trycatch.t
|
||||
t/02tryfinally.t
|
||||
|
@ -28,7 +33,3 @@ t/80defer+SKT.t
|
|||
t/90rt123547.t
|
||||
t/90rt125971.t
|
||||
t/99pod.t
|
||||
README
|
||||
LICENSE
|
||||
META.yml
|
||||
META.json
|
||||
|
|
10
META.json
10
META.json
|
@ -33,18 +33,18 @@
|
|||
},
|
||||
"test" : {
|
||||
"requires" : {
|
||||
"Test::More" : "0.88"
|
||||
"Test2::V0" : "0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"provides" : {
|
||||
"Syntax::Keyword::Try" : {
|
||||
"file" : "lib/Syntax/Keyword/Try.pm",
|
||||
"version" : "0.27"
|
||||
"version" : "0.29"
|
||||
},
|
||||
"Syntax::Keyword::Try::Deparse" : {
|
||||
"file" : "lib/Syntax/Keyword/Try/Deparse.pm",
|
||||
"version" : "0.27"
|
||||
"version" : "0.29"
|
||||
}
|
||||
},
|
||||
"release_status" : "stable",
|
||||
|
@ -54,6 +54,6 @@
|
|||
],
|
||||
"x_IRC" : "irc://irc.perl.org/#io-async"
|
||||
},
|
||||
"version" : "0.27",
|
||||
"x_serialization_backend" : "JSON::PP version 4.06"
|
||||
"version" : "0.29",
|
||||
"x_serialization_backend" : "JSON::PP version 4.07"
|
||||
}
|
||||
|
|
8
META.yml
8
META.yml
|
@ -4,7 +4,7 @@ author:
|
|||
- 'Paul Evans <leonerd@leonerd.org.uk>'
|
||||
build_requires:
|
||||
ExtUtils::CBuilder: '0'
|
||||
Test::More: '0.88'
|
||||
Test2::V0: '0'
|
||||
configure_requires:
|
||||
Module::Build: '0.4004'
|
||||
XS::Parse::Keyword::Builder: '0.06'
|
||||
|
@ -18,15 +18,15 @@ name: Syntax-Keyword-Try
|
|||
provides:
|
||||
Syntax::Keyword::Try:
|
||||
file: lib/Syntax/Keyword/Try.pm
|
||||
version: '0.27'
|
||||
version: '0.29'
|
||||
Syntax::Keyword::Try::Deparse:
|
||||
file: lib/Syntax/Keyword/Try/Deparse.pm
|
||||
version: '0.27'
|
||||
version: '0.29'
|
||||
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.27'
|
||||
version: '0.29'
|
||||
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
|
||||
|
|
|
@ -16,15 +16,6 @@ static OP *S_newAELEMOP(pTHX_ U32 flags, OP *first, I32 key)
|
|||
return newBINOP(OP_AELEM, flags, first, newSVOP(OP_CONST, 0, newSViv(key)));
|
||||
}
|
||||
|
||||
#define newPADxVOP(type, padix, flags, private) S_newPADxVOP(aTHX_ type, padix, flags, private)
|
||||
static OP *S_newPADxVOP(pTHX_ I32 type, PADOFFSET padix, I32 flags, U32 private)
|
||||
{
|
||||
OP *op = newOP(type, flags);
|
||||
op->op_targ = padix;
|
||||
op->op_private = private;
|
||||
return op;
|
||||
}
|
||||
|
||||
#if HAVE_PERL_VERSION(5, 22, 0)
|
||||
# define HAVE_UNOP_AUX
|
||||
#endif
|
||||
|
@ -80,3 +71,14 @@ static OP *S_newMETHOD_REDIR_OP(pTHX_ SV *rclass, SV *methname, I32 flags)
|
|||
|
||||
return op;
|
||||
}
|
||||
|
||||
/* If `@_` is called "snail", then elements of it can be called "slugs"; i.e.
|
||||
* snails without their container
|
||||
*/
|
||||
#define newSLUGOP(idx) S_newSLUGOP(aTHX_ idx)
|
||||
static OP *S_newSLUGOP(pTHX_ int idx)
|
||||
{
|
||||
OP *op = newGVOP(OP_AELEMFAST, 0, PL_defgv);
|
||||
op->op_private = idx;
|
||||
return op;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
/* vi: set ft=c : */
|
||||
|
||||
#ifndef av_count
|
||||
# define av_count(av) (AvFILL(av) + 1)
|
||||
#endif
|
||||
|
||||
#if HAVE_PERL_VERSION(5, 22, 0)
|
||||
# define PadnameIsNULL(pn) (!(pn))
|
||||
#else
|
||||
|
@ -30,16 +26,6 @@ static char *S_save_strndup(pTHX_ char *s, STRLEN l)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#define sv_setrv(s, r) S_sv_setrv(aTHX_ s, r)
|
||||
static void S_sv_setrv(pTHX_ SV *sv, SV *rv)
|
||||
{
|
||||
sv_setiv(sv, (IV)rv);
|
||||
#if !HAVE_PERL_VERSION(5, 24, 0)
|
||||
SvIOK_off(sv);
|
||||
#endif
|
||||
SvROK_on(sv);
|
||||
}
|
||||
|
||||
static char *PL_savetype_name[] PERL_UNUSED_DECL = {
|
||||
/* These have been present since 5.16 */
|
||||
[SAVEt_ADELETE] = "ADELETE",
|
||||
|
@ -249,15 +235,19 @@ static bool MY_lex_consume_unichar(pTHX_ U32 c)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#if HAVE_PERL_VERSION(5, 16, 0)
|
||||
/* TODO: perl 5.14 lacks HvNAMEUTF8, HvNAMELEN, sv_derived_from_pvn */
|
||||
# define sv_derived_from_hv(sv, hv) MY_sv_derived_from_hv(aTHX_ sv, hv)
|
||||
static bool MY_sv_derived_from_hv(pTHX_ SV *sv, HV *hv)
|
||||
#define av_push_from_av_inc(dst, src) S_av_push_from_av(aTHX_ dst, src, TRUE)
|
||||
#define av_push_from_av_noinc(dst, src) S_av_push_from_av(aTHX_ dst, src, FALSE)
|
||||
static void S_av_push_from_av(pTHX_ AV *dst, AV *src, bool refcnt_inc)
|
||||
{
|
||||
char *hvname = HvNAME(hv);
|
||||
if(!hvname)
|
||||
return FALSE;
|
||||
SSize_t count = av_count(src);
|
||||
SSize_t i;
|
||||
|
||||
return sv_derived_from_pvn(sv, hvname, HvNAMELEN(hv), HvNAMEUTF8(hv) ? SVf_UTF8 : 0);
|
||||
av_extend(dst, av_count(dst) + count - 1);
|
||||
|
||||
SV **vals = AvARRAY(src);
|
||||
|
||||
for(i = 0; i < count; i++) {
|
||||
SV *sv = vals[i];
|
||||
av_push(dst, refcnt_inc ? SvREFCNT_inc(sv) : sv);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_PERL_VERSION(5, 16, 0) */
|
||||
|
|
|
@ -23,6 +23,7 @@ typedef AV PADNAMELIST;
|
|||
typedef SV PADNAME;
|
||||
# define PadnamePV(pn) (SvPOKp(pn) ? SvPVX(pn) : NULL)
|
||||
# define PadnameLEN(pn) SvCUR(pn)
|
||||
# define PadnameIsSTATE(pn) (!!SvPAD_STATE(pn))
|
||||
# define PadnameOUTER(pn) (SvFAKE(pn) && !SvPAD_STATE(pn))
|
||||
# define PadnamelistARRAY(pnl) AvARRAY(pnl)
|
||||
# define PadnamelistMAX(pnl) AvFILLp(pnl)
|
||||
|
@ -31,6 +32,24 @@ typedef SV PADNAME;
|
|||
# define PadMAX(pad) AvFILLp(pad)
|
||||
#endif
|
||||
|
||||
#if !HAVE_PERL_VERSION(5, 22, 0)
|
||||
# define CvPADLIST_set(cv, padlist) (CvPADLIST(cv) = padlist)
|
||||
# define newPADNAMEpvn(p,n) S_newPADNAMEpvn(aTHX_ p,n)
|
||||
static PADNAME *S_newPADNAMEpvn(pTHX_ const char *pv, STRLEN n)
|
||||
{
|
||||
PADNAME *pn = newSVpvn(pv, n);
|
||||
/* PADNAMEs need to be at least SVt_PVNV in order to store the COP_SEQ_*
|
||||
* fields */
|
||||
sv_upgrade(pn, SVt_PVNV);
|
||||
return pn;
|
||||
}
|
||||
# define PadnameREFCNT_dec(pn) SvREFCNT_dec(pn)
|
||||
#endif
|
||||
|
||||
#ifndef av_count
|
||||
# define av_count(av) (AvFILL(av) + 1)
|
||||
#endif
|
||||
|
||||
#ifndef av_top_index
|
||||
# define av_top_index(av) AvFILL(av)
|
||||
#endif
|
||||
|
@ -43,6 +62,10 @@ typedef SV PADNAME;
|
|||
# define block_start(a) Perl_block_start(aTHX_ a)
|
||||
#endif
|
||||
|
||||
#ifndef cophh_exists_pvs
|
||||
# define cophh_exists_pvs(a,b,c) cBOOL(cophh_fetch_pvs(a,b,c))
|
||||
#endif
|
||||
|
||||
#ifndef cv_clone
|
||||
# define cv_clone(a) Perl_cv_clone(aTHX_ a)
|
||||
#endif
|
||||
|
@ -69,6 +92,10 @@ typedef SV PADNAME;
|
|||
# define OpSIBLING(op) ((op)->op_sibling)
|
||||
#endif
|
||||
|
||||
#ifndef OpHAS_SIBLING
|
||||
# define OpHAS_SIBLING(op) (cBOOL(OpSIBLING(op)))
|
||||
#endif
|
||||
|
||||
#ifndef OpMORESIB_set
|
||||
# define OpMORESIB_set(op,sib) ((op)->op_sibling = (sib))
|
||||
#endif
|
||||
|
@ -123,7 +150,7 @@ static OP *S_op_convert_list(pTHX_ I32 type, I32 flags, OP *o)
|
|||
/* On Perl 5.14 this had a different name */
|
||||
#ifndef pad_add_name_pvn
|
||||
#define pad_add_name_pvn(name, len, flags, typestash, ourstash) MY_pad_add_name(aTHX_ name, len, flags, typestash, ourstash)
|
||||
PADOFFSET MY_pad_add_name(pTHX_ const char *name, STRLEN len, U32 flags, HV *typestash, HV *ourstash)
|
||||
static PADOFFSET MY_pad_add_name(pTHX_ const char *name, STRLEN len, U32 flags, HV *typestash, HV *ourstash)
|
||||
{
|
||||
/* perl 5.14's Perl_pad_add_name requires a NUL-terminated name */
|
||||
SV *namesv = sv_2mortal(newSVpvn(name, len));
|
||||
|
@ -136,3 +163,60 @@ PADOFFSET MY_pad_add_name(pTHX_ const char *name, STRLEN len, U32 flags, HV *typ
|
|||
# define isIDFIRST_utf8_safe(s, e) (PERL_UNUSED_ARG(e), isIDFIRST_utf8(s))
|
||||
# define isIDCONT_utf8_safe(s, e) (PERL_UNUSED_ARG(e), isIDCONT_utf8(s))
|
||||
#endif
|
||||
|
||||
#ifndef CXp_EVALBLOCK
|
||||
/* before perl 5.34 this was called CXp_TRYBLOCK */
|
||||
# define CXp_EVALBLOCK CXp_TRYBLOCK
|
||||
#endif
|
||||
|
||||
#if !HAVE_PERL_VERSION(5, 26, 0)
|
||||
# define sv_set_undef(sv) sv_setsv(sv, &PL_sv_undef)
|
||||
#endif
|
||||
|
||||
#ifndef newAVav
|
||||
# define newAVav(av) S_newAVav(aTHX_ av)
|
||||
static AV *S_newAVav(pTHX_ AV *av)
|
||||
{
|
||||
AV *ret = newAV();
|
||||
U32 count = av_count(av);
|
||||
U32 i;
|
||||
for(i = 0; i < count; i++)
|
||||
av_push(ret, newSVsv(AvARRAY(av)[i]));
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(sv_derived_from_hv) && HAVE_PERL_VERSION(5, 16, 0)
|
||||
# define sv_derived_from_hv(sv, hv) MY_sv_derived_from_hv(aTHX_ sv, hv)
|
||||
static bool MY_sv_derived_from_hv(pTHX_ SV *sv, HV *hv)
|
||||
{
|
||||
char *hvname = HvNAME(hv);
|
||||
if(!hvname)
|
||||
return FALSE;
|
||||
|
||||
return sv_derived_from_pvn(sv, hvname, HvNAMELEN(hv), HvNAMEUTF8(hv) ? SVf_UTF8 : 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef xV_FROM_REF
|
||||
# ifdef PERL_USE_GCC_BRACE_GROUPS
|
||||
# define xV_FROM_REF(XV, ref) \
|
||||
({ SV *_ref = ref; assert(SvROK(_ref)); assert(SvTYPE(SvRV(_ref)) == SVt_PV ## XV); (XV *)(SvRV(_ref)); })
|
||||
# else
|
||||
# define xV_FROM_REF(XV, ref) ((XV *)SvRV(ref))
|
||||
# endif
|
||||
|
||||
# define AV_FROM_REF(ref) xV_FROM_REF(AV, ref)
|
||||
# define CV_FROM_REF(ref) xV_FROM_REF(CV, ref)
|
||||
# define HV_FROM_REF(ref) xV_FROM_REF(HV, ref)
|
||||
#endif
|
||||
|
||||
#ifndef newPADxVOP
|
||||
# define newPADxVOP(type, flags, padix) S_newPADxVOP(aTHX_ type, flags, padix)
|
||||
static OP *S_newPADxVOP(pTHX_ I32 type, I32 flags, PADOFFSET padix)
|
||||
{
|
||||
OP *op = newOP(type, flags);
|
||||
op->op_targ = padix;
|
||||
return op;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# You may distribute under the terms of either the GNU General Public License
|
||||
# or the Artistic License (the same terms as Perl itself)
|
||||
#
|
||||
# (C) Paul Evans, 2016-2022 -- leonerd@leonerd.org.uk
|
||||
# (C) Paul Evans, 2016-2023 -- leonerd@leonerd.org.uk
|
||||
|
||||
package Syntax::Keyword::Try 0.27;
|
||||
package Syntax::Keyword::Try 0.29;
|
||||
|
||||
use v5.14;
|
||||
use warnings;
|
||||
|
@ -353,38 +353,49 @@ L<https://rt.cpan.org/Ticket/Display.html?id=123918>.
|
|||
|
||||
sub import
|
||||
{
|
||||
my $class = shift;
|
||||
my $pkg = shift;
|
||||
my $caller = caller;
|
||||
|
||||
$class->import_into( $caller, @_ );
|
||||
$pkg->import_into( $caller, @_ );
|
||||
}
|
||||
|
||||
sub unimport
|
||||
{
|
||||
my $pkg = shift;
|
||||
my $caller = caller;
|
||||
|
||||
$pkg->unimport_into( $caller, @_ );
|
||||
}
|
||||
|
||||
my @EXPERIMENTAL = qw( typed );
|
||||
|
||||
sub import_into
|
||||
sub import_into { shift->apply( sub { $^H{ $_[0] }++ }, @_ ) }
|
||||
sub unimport_into { shift->apply( sub { delete $^H{ $_[0] } }, @_ ) }
|
||||
|
||||
sub apply
|
||||
{
|
||||
my $class = shift;
|
||||
my ( $caller, @syms ) = @_;
|
||||
my $pkg = shift;
|
||||
my ( $cb, $caller, @syms ) = @_;
|
||||
|
||||
@syms or @syms = qw( try );
|
||||
|
||||
my %syms = map { $_ => 1 } @syms;
|
||||
$^H{"Syntax::Keyword::Try/try"}++ if delete $syms{try};
|
||||
$cb->( "Syntax::Keyword::Try/try" ) if delete $syms{try};
|
||||
|
||||
# Largely for Feature::Compat::Try's benefit
|
||||
$^H{"Syntax::Keyword::Try/no_finally"}++ if delete $syms{"-no_finally"};
|
||||
$^H{"Syntax::Keyword::Try/require_catch"}++ if delete $syms{"-require_catch"};
|
||||
$^H{"Syntax::Keyword::Try/require_var"}++ if delete $syms{"-require_var"};
|
||||
$cb->( "Syntax::Keyword::Try/no_finally" ) if delete $syms{"-no_finally"};
|
||||
$cb->( "Syntax::Keyword::Try/require_catch" ) if delete $syms{"-require_catch"};
|
||||
$cb->( "Syntax::Keyword::Try/require_var" ) if delete $syms{"-require_var"};
|
||||
|
||||
# stablised experiments
|
||||
delete $syms{":experimental($_)"} for qw( var );
|
||||
|
||||
foreach ( @EXPERIMENTAL ) {
|
||||
$^H{"Syntax::Keyword::Try/experimental($_)"}++ if delete $syms{":experimental($_)"};
|
||||
$cb->( "Syntax::Keyword::Try/experimental($_)" ) if delete $syms{":experimental($_)"};
|
||||
}
|
||||
|
||||
if( delete $syms{":experimental"} ) {
|
||||
$^H{"Syntax::Keyword::Try/experimental($_)"}++ for @EXPERIMENTAL;
|
||||
$cb->( "Syntax::Keyword::Try/experimental($_)" ) for @EXPERIMENTAL;
|
||||
}
|
||||
|
||||
# Ignore requests for these, as they come automatically with `try`
|
||||
|
|
|
@ -179,7 +179,16 @@ static OP *MY_newLOCALISEOP(pTHX_ GV *gv)
|
|||
static OP *MY_newSTATEOP_nowarnings(pTHX)
|
||||
{
|
||||
OP *op = newSTATEOP(0, NULL, NULL);
|
||||
#if HAVE_PERL_VERSION(5,37,6)
|
||||
/* cop_warnings no longer has the weird STRLEN prefix on it
|
||||
* https://github.com/Perl/perl5/pull/20469
|
||||
*/
|
||||
char *warnings = ((COP *)op)->cop_warnings;
|
||||
# define WARNING_BITS warnings
|
||||
#else
|
||||
STRLEN *warnings = ((COP *)op)->cop_warnings;
|
||||
# define WARNING_BITS (char *)(warnings + 1)
|
||||
#endif
|
||||
char *warning_bits;
|
||||
|
||||
if(warnings == pWARN_NONE)
|
||||
|
@ -191,15 +200,17 @@ static OP *MY_newSTATEOP_nowarnings(pTHX)
|
|||
else if(warnings == pWARN_ALL)
|
||||
warning_bits = WARN_ALLstring;
|
||||
else
|
||||
warning_bits = (char *)(warnings + 1);
|
||||
warning_bits = WARNING_BITS;
|
||||
|
||||
warnings = Perl_new_warnings_bitfield(aTHX_ warnings, warning_bits, WARNsize);
|
||||
((COP *)op)->cop_warnings = warnings;
|
||||
|
||||
warning_bits = (char *)(warnings + 1);
|
||||
warning_bits = WARNING_BITS;
|
||||
warning_bits[(2*WARN_EXITING) / 8] &= ~(1 << (2*WARN_EXITING % 8));
|
||||
|
||||
return op;
|
||||
|
||||
#undef WARNING_BITS
|
||||
}
|
||||
|
||||
static void rethread_op(OP *op, OP *old, OP *new)
|
||||
|
@ -437,14 +448,14 @@ static int build_try(pTHX_ OP **out, XSParseKeywordPiece *args[], size_t nargs,
|
|||
OP *type = args[argi++]->op;
|
||||
#ifdef HAVE_OP_ISA
|
||||
condop = newBINOP(OP_ISA, 0,
|
||||
newPADxVOP(OP_PADSV, catchvar, 0, 0), type);
|
||||
newPADxVOP(OP_PADSV, 0, catchvar), type);
|
||||
#else
|
||||
/* Allow a bareword on RHS of `isa` */
|
||||
if(type->op_type == OP_CONST)
|
||||
type->op_private &= ~(OPpCONST_BARE|OPpCONST_STRICT);
|
||||
|
||||
condop = newBINOP_CUSTOM(&pp_isa, 0,
|
||||
newPADxVOP(OP_PADSV, catchvar, 0, 0), type);
|
||||
newPADxVOP(OP_PADSV, 0, catchvar), type);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -460,7 +471,7 @@ static int build_try(pTHX_ OP **out, XSParseKeywordPiece *args[], size_t nargs,
|
|||
regexp->op_targ = catchvar;
|
||||
#else
|
||||
/* Older perls need a stacked OP_PADSV op */
|
||||
cPMOPx(regexp)->op_first = newPADxVOP(OP_PADSV, catchvar, 0, 0);
|
||||
cPMOPx(regexp)->op_first = newPADxVOP(OP_PADSV, 0, catchvar);
|
||||
regexp->op_flags |= OPf_KIDS|OPf_STACKED;
|
||||
#endif
|
||||
condop = regexp;
|
||||
|
@ -492,7 +503,7 @@ static int build_try(pTHX_ OP **out, XSParseKeywordPiece *args[], size_t nargs,
|
|||
if(catchvar) {
|
||||
/* my $var = $@ */
|
||||
assignop = newBINOP(OP_SASSIGN, 0,
|
||||
newGVOP(OP_GVSV, 0, PL_errgv), newPADxVOP(OP_PADSV, catchvar, OPf_MOD, OPpLVAL_INTRO));
|
||||
newGVOP(OP_GVSV, 0, PL_errgv), newPADxVOP(OP_PADSV, OPf_MOD | OPpLVAL_INTRO << 8, catchvar));
|
||||
}
|
||||
|
||||
if(condop) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# (C) Paul Evans, 2021 -- leonerd@leonerd.org.uk
|
||||
|
||||
package Syntax::Keyword::Try::Deparse 0.27;
|
||||
package Syntax::Keyword::Try::Deparse 0.29;
|
||||
|
||||
use v5.14;
|
||||
use warnings;
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use_ok( "Syntax::Keyword::Try" );
|
||||
require Syntax::Keyword::Try;
|
||||
|
||||
pass( "Modules loaded" );
|
||||
done_testing;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try;
|
||||
|
||||
|
@ -120,4 +120,12 @@ use Syntax::Keyword::Try;
|
|||
ok( $destroyed, 'catch ($var) does not retain value' );
|
||||
}
|
||||
|
||||
{
|
||||
no Syntax::Keyword::Try;
|
||||
|
||||
sub try { return "normal function" }
|
||||
|
||||
is( try, "normal function", 'try() parses as a normal function call' );
|
||||
}
|
||||
|
||||
done_testing;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try qw( try :experimental );
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try;
|
||||
|
||||
|
@ -15,7 +15,7 @@ use Syntax::Keyword::Try;
|
|||
catch ($e) {}
|
||||
} )->( 1, 2, 3 );
|
||||
|
||||
is_deeply( \@args, [ 1, 2, 3 ], 'try{} sees surrounding @_' );
|
||||
is( \@args, [ 1, 2, 3 ], 'try{} sees surrounding @_' );
|
||||
}
|
||||
|
||||
# catch sees @_
|
||||
|
@ -26,7 +26,7 @@ use Syntax::Keyword::Try;
|
|||
catch ($e) { @args = @_ }
|
||||
} )->( 4, 5, 6 );
|
||||
|
||||
is_deeply( \@args, [ 4, 5, 6 ], 'catch{} sees @_' );
|
||||
is( \@args, [ 4, 5, 6 ], 'catch{} sees @_' );
|
||||
}
|
||||
|
||||
done_testing;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try;
|
||||
|
||||
|
@ -33,7 +33,7 @@ use Syntax::Keyword::Try;
|
|||
|
||||
# return LIST from try
|
||||
{
|
||||
is_deeply(
|
||||
is(
|
||||
[ sub {
|
||||
try { return qw( A B C ) } catch ($e) {}
|
||||
}->() ],
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try;
|
||||
|
||||
|
@ -19,7 +19,7 @@ use Syntax::Keyword::Try;
|
|||
try { 1, 2, 3 }
|
||||
catch ($e) { 4, 5, 6 }
|
||||
};
|
||||
is_deeply(\@list, [1, 2, 3], 'do { try } in list context');
|
||||
is(\@list, [1, 2, 3], 'do { try } in list context');
|
||||
}
|
||||
|
||||
# catch as final expression yields correct value
|
||||
|
@ -34,7 +34,7 @@ use Syntax::Keyword::Try;
|
|||
try { die "Oops" }
|
||||
catch ($e) { 4, 5, 6 }
|
||||
};
|
||||
is_deeply(\@list, [4, 5, 6], 'do { try/catch } in list context');
|
||||
is(\@list, [4, 5, 6], 'do { try/catch } in list context');
|
||||
|
||||
$scalar = do {
|
||||
try { die "Oops" }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try;
|
||||
use Syntax::Keyword::Try::Deparse;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
BEGIN {
|
||||
plan skip_all => "Future is not available"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
BEGIN {
|
||||
plan skip_all => "Syntax::Keyword::Defer >= 0.02 is not available"
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
use Test2::IPC;
|
||||
|
||||
# RT123547 observes that if S:K:T is loaded late after multiple threads
|
||||
# are actually started, it will crash
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use v5.14;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test2::V0;
|
||||
|
||||
use Syntax::Keyword::Try;
|
||||
|
||||
|
@ -31,7 +31,7 @@ sub outer
|
|||
return @result;
|
||||
}
|
||||
|
||||
is_deeply [ outer() ], [ 1, 123 ], "No extra data in return";
|
||||
is [ outer() ], [ 1, 123 ], "No extra data in return";
|
||||
|
||||
done_testing;
|
||||
|
||||
|
|
Loading…
Reference in New Issue