From 16ab164090761445bc5a32e7c402cd2f195d017a Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Sun, 27 Nov 2022 15:44:33 +0000 Subject: Deparse.pm: Correctly handle signature //= and ||= params --- lib/B/Deparse.pm | 6 +++++- lib/B/Deparse.t | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm index d84d2a2709..6754def76d 100644 --- a/lib/B/Deparse.pm +++ b/lib/B/Deparse.pm @@ -23,6 +23,7 @@ use B qw(class main_root main_start main_cv svref_2object opnumber perlstring OPpCONCAT_NESTED OPpMULTICONCAT_APPEND OPpMULTICONCAT_STRINGIFY OPpMULTICONCAT_FAKE OPpTRUEBOOL OPpINDEX_BOOLNEG OPpDEFER_FINALLY + OPpARG_IF_UNDEF OPpARG_IF_FALSE SVf_IOK SVf_NOK SVf_ROK SVf_POK SVf_FAKE SVs_RMG SVs_SMG SVs_PADTMP CVf_NOWARN_AMBIGUOUS CVf_LVALUE @@ -1261,7 +1262,10 @@ sub deparse_argops { return unless $$kid and $kid->name eq 'argdefelem'; my $def = $self->deparse($kid->first, 7); $def = "($def)" if $kid->first->flags & OPf_PARENS; - $var .= " = $def"; + my $assign = "="; + $assign = "//=" if $kid->private & OPpARG_IF_UNDEF; + $assign = "||=" if $kid->private & OPpARG_IF_FALSE; + $var .= " $assign $def"; } push @sig, $var; } diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t index 492d3070b2..c7a3307a9a 100644 --- a/lib/B/Deparse.t +++ b/lib/B/Deparse.t @@ -2752,6 +2752,22 @@ sub ($a, $=) { } ; #### +# defined-or default +no warnings; +use feature 'signatures'; +sub ($a //= 'default') { + $a; +} +; +#### +# logical-or default +no warnings; +use feature 'signatures'; +sub ($a ||= 'default') { + $a; +} +; +#### # padrange op within pattern code blocks /(?{ my($x, $y) = (); })/; my $a; -- cgit v1.2.1