summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2022-11-19 11:48:19 +0000
committerPaul Evans <leonerd@leonerd.org.uk>2022-11-26 15:47:22 +0000
commitf17d9825ab9b50967fd3d8742cc1bbccec96c049 (patch)
tree1835ae9ad258f5fadd48b08c96b33887768c3352 /toke.c
parent5bd919dc87af18e1bce77d3ead83b704a2903292 (diff)
downloadperl-f17d9825ab9b50967fd3d8742cc1bbccec96c049.tar.gz
Recognise `//=` and `||=` syntax in signature parameter defaults
These create parameters where the default expression is assigned whenever the caller did not pass a defined (or true) value. I.e. both if it is missing, or is present but undef (or false).
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/toke.c b/toke.c
index 8872d3c212..edc2690934 100644
--- a/toke.c
+++ b/toke.c
@@ -5090,7 +5090,23 @@ yyl_sigvar(pTHX_ char *s)
PL_oldbufptr = s;
++s;
- NEXTVAL_NEXTTOKE.ival = 0;
+ NEXTVAL_NEXTTOKE.ival = OP_SASSIGN;
+ force_next(ASSIGNOP);
+ PL_expect = XTERM;
+ }
+ else if(*s == '/' && s[1] == '/' && s[2] == '=') {
+ PL_oldbufptr = s;
+
+ s += 3;
+ NEXTVAL_NEXTTOKE.ival = OP_DORASSIGN;
+ force_next(ASSIGNOP);
+ PL_expect = XTERM;
+ }
+ else if(*s == '|' && s[1] == '|' && s[2] == '=') {
+ PL_oldbufptr = s;
+
+ s += 3;
+ NEXTVAL_NEXTTOKE.ival = OP_ORASSIGN;
force_next(ASSIGNOP);
PL_expect = XTERM;
}