diff options
author | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2022-11-19 11:48:19 +0000 |
---|---|---|
committer | Paul Evans <leonerd@leonerd.org.uk> | 2022-11-26 15:47:22 +0000 |
commit | f17d9825ab9b50967fd3d8742cc1bbccec96c049 (patch) | |
tree | 1835ae9ad258f5fadd48b08c96b33887768c3352 /toke.c | |
parent | 5bd919dc87af18e1bce77d3ead83b704a2903292 (diff) | |
download | perl-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.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -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; } |