From c930524a1e0560b81589a2f0b9e7bc796355a9ca Mon Sep 17 00:00:00 2001 From: James E Keenan Date: Tue, 20 Aug 2024 12:08:47 -0400 Subject: [PATCH] Limit given/when/switch functionality by Perl version Also limit version scope of tests for switch. 'given', 'when', 'switch' functionality and smartmatch operator removed in perl-5.41.3. --- Upper.xs | 10 +++++----- t/lib/Scope/Upper/TestGenerator.pm | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Upper.xs b/Upper.xs index 7be4f69..fd70516 100644 --- a/Upper.xs +++ b/Upper.xs @@ -1425,7 +1425,7 @@ static void su_yield(pTHX_ void *ud_) { OP *o = NULL; /* Is this actually a given/when block? This may occur only when yield was * called with HERE (or nothing) as the context. */ -#if XSH_HAS_PERL(5, 10, 0) +#if XSH_HAS_PERL(5, 10, 0) && !XSH_HAS_PERL(5, 41, 2) if (cxix > 0) { PERL_CONTEXT *prev = cx - 1; U8 prev_type = CxTYPE(prev); @@ -1526,7 +1526,7 @@ static void su_yield(pTHX_ void *ud_) { type = OP_LEAVELOOP; next = SU_RETOP_LOOP(cx); break; -#if XSH_HAS_PERL(5, 10, 0) +#if XSH_HAS_PERL(5, 10, 0) && !XSH_HAS_PERL(5, 41, 2) case CXt_GIVEN: cxt_given: type = OP_LEAVEGIVEN; @@ -1534,7 +1534,7 @@ cxt_given: break; case CXt_WHEN: cxt_when: -#if XSH_HAS_PERL(5, 15, 1) +#if XSH_HAS_PERL(5, 15, 1) && !XSH_HAS_PERL(5, 41, 2) type = OP_LEAVEWHEN; #else type = OP_BREAK; @@ -2536,7 +2536,7 @@ static I32 su_context_normalize_up(pTHX_ I32 cxix) { PERL_CONTEXT *prev = cx - 1; switch (CxTYPE(prev)) { -#if XSH_HAS_PERL(5, 10, 0) +#if XSH_HAS_PERL(5, 10, 0) && !XSH_HAS_PERL(5, 41, 2) case CXt_GIVEN: case CXt_WHEN: #endif @@ -2572,7 +2572,7 @@ static I32 su_context_normalize_down(pTHX_ I32 cxix) { PERL_CONTEXT *cx = next - 1; switch (CxTYPE(cx)) { -#if XSH_HAS_PERL(5, 10, 0) +#if XSH_HAS_PERL(5, 10, 0) && !XSH_HAS_PERL(5, 41, 2) case CXt_GIVEN: case CXt_WHEN: #endif diff --git a/t/lib/Scope/Upper/TestGenerator.pm b/t/lib/Scope/Upper/TestGenerator.pm index df175ac..707f2c2 100644 --- a/t/lib/Scope/Upper/TestGenerator.pm +++ b/t/lib/Scope/Upper/TestGenerator.pm @@ -44,7 +44,7 @@ sub import { warnings->unimport('experimental::smartmatch'); } - if ("$]" >= 5.010_001) { + if ("$]" >= 5.010_001 && "$]" <= 5.041_002) { require feature; feature->import('switch'); } -- 2.34.1