summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2022-11-27 15:44:33 +0000
committerPaul Evans <leonerd@leonerd.org.uk>2022-11-30 13:54:08 +0000
commit16ab164090761445bc5a32e7c402cd2f195d017a (patch)
tree7a166c752296431a28ce941308d75523ad5aac19 /lib
parent74138d37463ce0323abfc079dbea510bc80244c2 (diff)
downloadperl-16ab164090761445bc5a32e7c402cd2f195d017a.tar.gz
Deparse.pm: Correctly handle signature //= and ||= params
Diffstat (limited to 'lib')
-rw-r--r--lib/B/Deparse.pm6
-rw-r--r--lib/B/Deparse.t16
2 files changed, 21 insertions, 1 deletions
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;