From f17d9825ab9b50967fd3d8742cc1bbccec96c049 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Sat, 19 Nov 2022 11:48:19 +0000 Subject: 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). --- toke.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'toke.c') 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; } -- cgit v1.2.1