summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2018-01-16 08:04:08 +0000
committerZefram <zefram@fysh.org>2018-01-16 08:04:08 +0000
commit097ff42c3bba30230d3512b3de153c75cd2e43c9 (patch)
treef4fd9e0d212719451844928c695b853a1ac28617 /perly.y
parent6661956a23de82b41adc406200054293d6d7aded (diff)
downloadperl-097ff42c3bba30230d3512b3de153c75cd2e43c9.tar.gz
fix parsing of braced subscript after parens
Where an arrow is omitted between subscripts, if a parenthesised subscript is followed by a braced one, PL_expect was getting set to XBLOCK due to code intended for "foreach (...) {...}". This broke bareword autoquotation, and the parsing of operators following the braced subscript. Alter PL_expect from XBLOCK to XOPERATOR following a parenthesised subscript. Fixes [perl #8045].
Diffstat (limited to 'perly.y')
-rw-r--r--perly.y20
1 files changed, 16 insertions, 4 deletions
diff --git a/perly.y b/perly.y
index 8f3e303af1..45536f2217 100644
--- a/perly.y
+++ b/perly.y
@@ -940,19 +940,31 @@ subscripted: gelem '{' expr ';' '}' /* *main::{something} */
jmaybe($3)); }
| term ARROW '(' ')' /* $subref->() */
{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
- newCVREF(0, scalar($1))); }
+ newCVREF(0, scalar($1)));
+ if (parser->expect == XBLOCK)
+ parser->expect = XOPERATOR;
+ }
| term ARROW '(' expr ')' /* $subref->(@args) */
{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
op_append_elem(OP_LIST, $4,
- newCVREF(0, scalar($1)))); }
+ newCVREF(0, scalar($1))));
+ if (parser->expect == XBLOCK)
+ parser->expect = XOPERATOR;
+ }
| subscripted '(' expr ')' /* $foo->{bar}->(@args) */
{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
op_append_elem(OP_LIST, $3,
- newCVREF(0, scalar($1)))); }
+ newCVREF(0, scalar($1))));
+ if (parser->expect == XBLOCK)
+ parser->expect = XOPERATOR;
+ }
| subscripted '(' ')' /* $foo->{bar}->() */
{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
- newCVREF(0, scalar($1))); }
+ newCVREF(0, scalar($1)));
+ if (parser->expect == XBLOCK)
+ parser->expect = XOPERATOR;
+ }
| '(' expr ')' '[' expr ']' /* list slice */
{ $$ = newSLICEOP(0, $5, $2); }
| QWLIST '[' expr ']' /* list literal slice */