Blob Blame History Raw
From 52ef21e43af97a7ed71a9bb7621a3c058196cfc2 Mon Sep 17 00:00:00 2001
From: Zefram <zefram@fysh.org>
Date: Tue, 16 Jan 2018 08:04:08 +0000
Subject: [PATCH] fix parsing of braced subscript after parens
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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].

Petr Písař: Ported to 5.26.1.

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 perly.act           | 250 +++++++++++++++++++++++++++-------------------------
 perly.h             |  10 ++-
 perly.tab           |  30 +++----
 perly.y             |  20 ++++-
 t/op/postfixderef.t |  25 +++++-
 5 files changed, 192 insertions(+), 143 deletions(-)

diff --git a/perly.act b/perly.act
index 73c44e5..4f74883 100644
--- a/perly.act
+++ b/perly.act
@@ -1194,65 +1194,77 @@ case 2:
   case 141:
 #line 931 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED,
-				   newCVREF(0, scalar((ps[-3].val.opval)))); }
+				   newCVREF(0, scalar((ps[-3].val.opval))));
+			  if (parser->expect == XBLOCK)
+			      parser->expect = XOPERATOR;
+			}
 
     break;
 
   case 142:
-#line 934 "perly.y" /* yacc.c:1646  */
+#line 937 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED,
 				   op_append_elem(OP_LIST, (ps[-1].val.opval),
-				       newCVREF(0, scalar((ps[-4].val.opval))))); }
+				       newCVREF(0, scalar((ps[-4].val.opval)))));
+			  if (parser->expect == XBLOCK)
+			      parser->expect = XOPERATOR;
+			}
 
     break;
 
   case 143:
-#line 939 "perly.y" /* yacc.c:1646  */
+#line 945 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED,
 				   op_append_elem(OP_LIST, (ps[-1].val.opval),
-					       newCVREF(0, scalar((ps[-3].val.opval))))); }
+					       newCVREF(0, scalar((ps[-3].val.opval)))));
+			  if (parser->expect == XBLOCK)
+			      parser->expect = XOPERATOR;
+			}
 
     break;
 
   case 144:
-#line 943 "perly.y" /* yacc.c:1646  */
+#line 952 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED,
-				   newCVREF(0, scalar((ps[-2].val.opval)))); }
+				   newCVREF(0, scalar((ps[-2].val.opval))));
+			  if (parser->expect == XBLOCK)
+			      parser->expect = XOPERATOR;
+			}
 
     break;
 
   case 145:
-#line 946 "perly.y" /* yacc.c:1646  */
+#line 958 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newSLICEOP(0, (ps[-1].val.opval), (ps[-4].val.opval)); }
 
     break;
 
   case 146:
-#line 948 "perly.y" /* yacc.c:1646  */
+#line 960 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newSLICEOP(0, (ps[-1].val.opval), (ps[-3].val.opval)); }
 
     break;
 
   case 147:
-#line 950 "perly.y" /* yacc.c:1646  */
+#line 962 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newSLICEOP(0, (ps[-1].val.opval), NULL); }
 
     break;
 
   case 148:
-#line 955 "perly.y" /* yacc.c:1646  */
+#line 967 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newASSIGNOP(OPf_STACKED, (ps[-2].val.opval), (ps[-1].val.ival), (ps[0].val.opval)); }
 
     break;
 
   case 149:
-#line 957 "perly.y" /* yacc.c:1646  */
+#line 969 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newBINOP((ps[-1].val.ival), 0, scalar((ps[-2].val.opval)), scalar((ps[0].val.opval))); }
 
     break;
 
   case 150:
-#line 959 "perly.y" /* yacc.c:1646  */
+#line 971 "perly.y" /* yacc.c:1646  */
     {   if ((ps[-1].val.ival) != OP_REPEAT)
 				scalar((ps[-2].val.opval));
 			    (yyval.opval) = newBINOP((ps[-1].val.ival), 0, (ps[-2].val.opval), scalar((ps[0].val.opval)));
@@ -1261,111 +1273,111 @@ case 2:
     break;
 
   case 151:
-#line 964 "perly.y" /* yacc.c:1646  */
+#line 976 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newBINOP((ps[-1].val.ival), 0, scalar((ps[-2].val.opval)), scalar((ps[0].val.opval))); }
 
     break;
 
   case 152:
-#line 966 "perly.y" /* yacc.c:1646  */
+#line 978 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newBINOP((ps[-1].val.ival), 0, scalar((ps[-2].val.opval)), scalar((ps[0].val.opval))); }
 
     break;
 
   case 153:
-#line 968 "perly.y" /* yacc.c:1646  */
+#line 980 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newBINOP((ps[-1].val.ival), 0, scalar((ps[-2].val.opval)), scalar((ps[0].val.opval))); }
 
     break;
 
   case 154:
-#line 970 "perly.y" /* yacc.c:1646  */
+#line 982 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newBINOP((ps[-1].val.ival), 0, scalar((ps[-2].val.opval)), scalar((ps[0].val.opval))); }
 
     break;
 
   case 155:
-#line 972 "perly.y" /* yacc.c:1646  */
+#line 984 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newBINOP((ps[-1].val.ival), 0, scalar((ps[-2].val.opval)), scalar((ps[0].val.opval))); }
 
     break;
 
   case 156:
-#line 974 "perly.y" /* yacc.c:1646  */
+#line 986 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newBINOP((ps[-1].val.ival), 0, scalar((ps[-2].val.opval)), scalar((ps[0].val.opval))); }
 
     break;
 
   case 157:
-#line 976 "perly.y" /* yacc.c:1646  */
+#line 988 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newRANGE((ps[-1].val.ival), scalar((ps[-2].val.opval)), scalar((ps[0].val.opval))); }
 
     break;
 
   case 158:
-#line 978 "perly.y" /* yacc.c:1646  */
+#line 990 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newLOGOP(OP_AND, 0, (ps[-2].val.opval), (ps[0].val.opval)); }
 
     break;
 
   case 159:
-#line 980 "perly.y" /* yacc.c:1646  */
+#line 992 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newLOGOP(OP_OR, 0, (ps[-2].val.opval), (ps[0].val.opval)); }
 
     break;
 
   case 160:
-#line 982 "perly.y" /* yacc.c:1646  */
+#line 994 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newLOGOP(OP_DOR, 0, (ps[-2].val.opval), (ps[0].val.opval)); }
 
     break;
 
   case 161:
-#line 984 "perly.y" /* yacc.c:1646  */
+#line 996 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = bind_match((ps[-1].val.ival), (ps[-2].val.opval), (ps[0].val.opval)); }
 
     break;
 
   case 162:
-#line 989 "perly.y" /* yacc.c:1646  */
+#line 1001 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_NEGATE, 0, scalar((ps[0].val.opval))); }
 
     break;
 
   case 163:
-#line 991 "perly.y" /* yacc.c:1646  */
+#line 1003 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 164:
-#line 994 "perly.y" /* yacc.c:1646  */
+#line 1006 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_NOT, 0, scalar((ps[0].val.opval))); }
 
     break;
 
   case 165:
-#line 996 "perly.y" /* yacc.c:1646  */
+#line 1008 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP((ps[-1].val.ival), 0, scalar((ps[0].val.opval))); }
 
     break;
 
   case 166:
-#line 998 "perly.y" /* yacc.c:1646  */
+#line 1010 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_POSTINC, 0,
 					op_lvalue(scalar((ps[-1].val.opval)), OP_POSTINC)); }
 
     break;
 
   case 167:
-#line 1001 "perly.y" /* yacc.c:1646  */
+#line 1013 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_POSTDEC, 0,
 					op_lvalue(scalar((ps[-1].val.opval)), OP_POSTDEC));}
 
     break;
 
   case 168:
-#line 1004 "perly.y" /* yacc.c:1646  */
+#line 1016 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = op_convert_list(OP_JOIN, 0,
 				       op_append_elem(
 					OP_LIST,
@@ -1380,52 +1392,52 @@ case 2:
     break;
 
   case 169:
-#line 1015 "perly.y" /* yacc.c:1646  */
+#line 1027 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_PREINC, 0,
 					op_lvalue(scalar((ps[0].val.opval)), OP_PREINC)); }
 
     break;
 
   case 170:
-#line 1018 "perly.y" /* yacc.c:1646  */
+#line 1030 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_PREDEC, 0,
 					op_lvalue(scalar((ps[0].val.opval)), OP_PREDEC)); }
 
     break;
 
   case 171:
-#line 1025 "perly.y" /* yacc.c:1646  */
+#line 1037 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newANONLIST((ps[-1].val.opval)); }
 
     break;
 
   case 172:
-#line 1027 "perly.y" /* yacc.c:1646  */
+#line 1039 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newANONLIST(NULL);}
 
     break;
 
   case 173:
-#line 1029 "perly.y" /* yacc.c:1646  */
+#line 1041 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newANONHASH((ps[-2].val.opval)); }
 
     break;
 
   case 174:
-#line 1031 "perly.y" /* yacc.c:1646  */
+#line 1043 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newANONHASH(NULL); }
 
     break;
 
   case 175:
-#line 1033 "perly.y" /* yacc.c:1646  */
+#line 1045 "perly.y" /* yacc.c:1646  */
     { SvREFCNT_inc_simple_void(PL_compcv);
 			  (yyval.opval) = newANONATTRSUB((ps[-3].val.ival), (ps[-2].val.opval), (ps[-1].val.opval), (ps[0].val.opval)); }
 
     break;
 
   case 176:
-#line 1036 "perly.y" /* yacc.c:1646  */
+#line 1048 "perly.y" /* yacc.c:1646  */
     {
 			  OP *body;
 			  if (parser->copline > (line_t)(ps[-2].val.ival))
@@ -1439,103 +1451,103 @@ case 2:
     break;
 
   case 177:
-#line 1050 "perly.y" /* yacc.c:1646  */
+#line 1062 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = dofile((ps[0].val.opval), (ps[-1].val.ival));}
 
     break;
 
   case 178:
-#line 1052 "perly.y" /* yacc.c:1646  */
+#line 1064 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_NULL, OPf_SPECIAL, op_scope((ps[0].val.opval)));}
 
     break;
 
   case 183:
-#line 1060 "perly.y" /* yacc.c:1646  */
+#line 1072 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newCONDOP(0, (ps[-4].val.opval), (ps[-2].val.opval), (ps[0].val.opval)); }
 
     break;
 
   case 184:
-#line 1062 "perly.y" /* yacc.c:1646  */
+#line 1074 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_REFGEN, 0, (ps[0].val.opval)); }
 
     break;
 
   case 185:
-#line 1064 "perly.y" /* yacc.c:1646  */
+#line 1076 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_REFGEN, 0, localize((ps[0].val.opval),1)); }
 
     break;
 
   case 186:
-#line 1066 "perly.y" /* yacc.c:1646  */
+#line 1078 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 187:
-#line 1068 "perly.y" /* yacc.c:1646  */
+#line 1080 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = localize((ps[0].val.opval),0); }
 
     break;
 
   case 188:
-#line 1070 "perly.y" /* yacc.c:1646  */
+#line 1082 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = sawparens((ps[-1].val.opval)); }
 
     break;
 
   case 189:
-#line 1072 "perly.y" /* yacc.c:1646  */
+#line 1084 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 190:
-#line 1074 "perly.y" /* yacc.c:1646  */
+#line 1086 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = sawparens(newNULLLIST()); }
 
     break;
 
   case 191:
-#line 1076 "perly.y" /* yacc.c:1646  */
+#line 1088 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 192:
-#line 1078 "perly.y" /* yacc.c:1646  */
+#line 1090 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 193:
-#line 1080 "perly.y" /* yacc.c:1646  */
+#line 1092 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 194:
-#line 1082 "perly.y" /* yacc.c:1646  */
+#line 1094 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 195:
-#line 1084 "perly.y" /* yacc.c:1646  */
+#line 1096 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_AV2ARYLEN, 0, ref((ps[0].val.opval), OP_AV2ARYLEN));}
 
     break;
 
   case 196:
-#line 1086 "perly.y" /* yacc.c:1646  */
+#line 1098 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 197:
-#line 1088 "perly.y" /* yacc.c:1646  */
+#line 1100 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = op_prepend_elem(OP_ASLICE,
 				newOP(OP_PUSHMARK, 0),
 				    newLISTOP(OP_ASLICE, 0,
@@ -1549,7 +1561,7 @@ case 2:
     break;
 
   case 198:
-#line 1098 "perly.y" /* yacc.c:1646  */
+#line 1110 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = op_prepend_elem(OP_KVASLICE,
 				newOP(OP_PUSHMARK, 0),
 				    newLISTOP(OP_KVASLICE, 0,
@@ -1563,7 +1575,7 @@ case 2:
     break;
 
   case 199:
-#line 1108 "perly.y" /* yacc.c:1646  */
+#line 1120 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = op_prepend_elem(OP_HSLICE,
 				newOP(OP_PUSHMARK, 0),
 				    newLISTOP(OP_HSLICE, 0,
@@ -1577,7 +1589,7 @@ case 2:
     break;
 
   case 200:
-#line 1118 "perly.y" /* yacc.c:1646  */
+#line 1130 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = op_prepend_elem(OP_KVHSLICE,
 				newOP(OP_PUSHMARK, 0),
 				    newLISTOP(OP_KVHSLICE, 0,
@@ -1591,26 +1603,26 @@ case 2:
     break;
 
   case 201:
-#line 1128 "perly.y" /* yacc.c:1646  */
+#line 1140 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 202:
-#line 1130 "perly.y" /* yacc.c:1646  */
+#line 1142 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_ENTERSUB, 0, scalar((ps[0].val.opval))); }
 
     break;
 
   case 203:
-#line 1132 "perly.y" /* yacc.c:1646  */
+#line 1144 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar((ps[-2].val.opval)));
 			}
 
     break;
 
   case 204:
-#line 1135 "perly.y" /* yacc.c:1646  */
+#line 1147 "perly.y" /* yacc.c:1646  */
     {
 			  (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED,
 				op_append_elem(OP_LIST, (ps[-1].val.opval), scalar((ps[-3].val.opval))));
@@ -1619,7 +1631,7 @@ case 2:
     break;
 
   case 205:
-#line 1140 "perly.y" /* yacc.c:1646  */
+#line 1152 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED,
 			    op_append_elem(OP_LIST, (ps[0].val.opval), scalar((ps[-1].val.opval))));
 			}
@@ -1627,130 +1639,130 @@ case 2:
     break;
 
   case 206:
-#line 1144 "perly.y" /* yacc.c:1646  */
+#line 1156 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newSVREF((ps[-3].val.opval)); }
 
     break;
 
   case 207:
-#line 1146 "perly.y" /* yacc.c:1646  */
+#line 1158 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newAVREF((ps[-3].val.opval)); }
 
     break;
 
   case 208:
-#line 1148 "perly.y" /* yacc.c:1646  */
+#line 1160 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newHVREF((ps[-3].val.opval)); }
 
     break;
 
   case 209:
-#line 1150 "perly.y" /* yacc.c:1646  */
+#line 1162 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_ENTERSUB, 0,
 				       scalar(newCVREF((ps[-1].val.ival),(ps[-3].val.opval)))); }
 
     break;
 
   case 210:
-#line 1153 "perly.y" /* yacc.c:1646  */
+#line 1165 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newGVREF(0,(ps[-3].val.opval)); }
 
     break;
 
   case 211:
-#line 1155 "perly.y" /* yacc.c:1646  */
+#line 1167 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newOP((ps[0].val.ival), OPf_SPECIAL);
 			    PL_hints |= HINT_BLOCK_SCOPE; }
 
     break;
 
   case 212:
-#line 1158 "perly.y" /* yacc.c:1646  */
+#line 1170 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newLOOPEX((ps[-1].val.ival),(ps[0].val.opval)); }
 
     break;
 
   case 213:
-#line 1160 "perly.y" /* yacc.c:1646  */
+#line 1172 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_NOT, 0, scalar((ps[0].val.opval))); }
 
     break;
 
   case 214:
-#line 1162 "perly.y" /* yacc.c:1646  */
+#line 1174 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newOP((ps[0].val.ival), 0); }
 
     break;
 
   case 215:
-#line 1164 "perly.y" /* yacc.c:1646  */
+#line 1176 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP((ps[-1].val.ival), 0, (ps[0].val.opval)); }
 
     break;
 
   case 216:
-#line 1166 "perly.y" /* yacc.c:1646  */
+#line 1178 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP((ps[-1].val.ival), 0, (ps[0].val.opval)); }
 
     break;
 
   case 217:
-#line 1168 "perly.y" /* yacc.c:1646  */
+#line 1180 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newOP(OP_REQUIRE, (ps[0].val.ival) ? OPf_SPECIAL : 0); }
 
     break;
 
   case 218:
-#line 1170 "perly.y" /* yacc.c:1646  */
+#line 1182 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_REQUIRE, (ps[-1].val.ival) ? OPf_SPECIAL : 0, (ps[0].val.opval)); }
 
     break;
 
   case 219:
-#line 1172 "perly.y" /* yacc.c:1646  */
+#line 1184 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar((ps[0].val.opval))); }
 
     break;
 
   case 220:
-#line 1174 "perly.y" /* yacc.c:1646  */
+#line 1186 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED,
 			    op_append_elem(OP_LIST, (ps[0].val.opval), scalar((ps[-1].val.opval)))); }
 
     break;
 
   case 221:
-#line 1177 "perly.y" /* yacc.c:1646  */
+#line 1189 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newOP((ps[0].val.ival), 0); }
 
     break;
 
   case 222:
-#line 1179 "perly.y" /* yacc.c:1646  */
+#line 1191 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newOP((ps[-2].val.ival), 0);}
 
     break;
 
   case 223:
-#line 1181 "perly.y" /* yacc.c:1646  */
+#line 1193 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 224:
-#line 1183 "perly.y" /* yacc.c:1646  */
+#line 1195 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[-2].val.opval); }
 
     break;
 
   case 225:
-#line 1185 "perly.y" /* yacc.c:1646  */
+#line 1197 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar((ps[0].val.opval))); }
 
     break;
 
   case 226:
-#line 1187 "perly.y" /* yacc.c:1646  */
+#line 1199 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = ((ps[-2].val.ival) == OP_NOT)
                           ? newUNOP((ps[-2].val.ival), 0, newSVOP(OP_CONST, 0, newSViv(0)))
                           : newOP((ps[-2].val.ival), OPf_SPECIAL); }
@@ -1758,13 +1770,13 @@ case 2:
     break;
 
   case 227:
-#line 1191 "perly.y" /* yacc.c:1646  */
+#line 1203 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP((ps[-3].val.ival), 0, (ps[-1].val.opval)); }
 
     break;
 
   case 228:
-#line 1193 "perly.y" /* yacc.c:1646  */
+#line 1205 "perly.y" /* yacc.c:1646  */
     {
 			    if (   (ps[0].val.opval)->op_type != OP_TRANS
 			        && (ps[0].val.opval)->op_type != OP_TRANSR
@@ -1779,13 +1791,13 @@ case 2:
     break;
 
   case 229:
-#line 1204 "perly.y" /* yacc.c:1646  */
+#line 1216 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = pmruntime((ps[-5].val.opval), (ps[-2].val.opval), (ps[-1].val.opval), 1, (ps[-4].val.ival)); }
 
     break;
 
   case 232:
-#line 1208 "perly.y" /* yacc.c:1646  */
+#line 1220 "perly.y" /* yacc.c:1646  */
     {
 			  (yyval.opval) = newLISTOP(OP_DIE, 0, newOP(OP_PUSHMARK, 0),
 				newSVOP(OP_CONST, 0, newSVpvs("Unimplemented")));
@@ -1794,109 +1806,109 @@ case 2:
     break;
 
   case 234:
-#line 1217 "perly.y" /* yacc.c:1646  */
+#line 1229 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = my_attrs((ps[-1].val.opval),(ps[0].val.opval)); }
 
     break;
 
   case 235:
-#line 1219 "perly.y" /* yacc.c:1646  */
+#line 1231 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = localize((ps[0].val.opval),1); }
 
     break;
 
   case 236:
-#line 1221 "perly.y" /* yacc.c:1646  */
+#line 1233 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newUNOP(OP_REFGEN, 0, my_attrs((ps[-1].val.opval),(ps[0].val.opval))); }
 
     break;
 
   case 237:
-#line 1226 "perly.y" /* yacc.c:1646  */
+#line 1238 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = sawparens((ps[-1].val.opval)); }
 
     break;
 
   case 238:
-#line 1228 "perly.y" /* yacc.c:1646  */
+#line 1240 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = sawparens(newNULLLIST()); }
 
     break;
 
   case 239:
-#line 1231 "perly.y" /* yacc.c:1646  */
+#line 1243 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 240:
-#line 1233 "perly.y" /* yacc.c:1646  */
+#line 1245 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 241:
-#line 1235 "perly.y" /* yacc.c:1646  */
+#line 1247 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 242:
-#line 1240 "perly.y" /* yacc.c:1646  */
+#line 1252 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = NULL; }
 
     break;
 
   case 243:
-#line 1242 "perly.y" /* yacc.c:1646  */
+#line 1254 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 244:
-#line 1246 "perly.y" /* yacc.c:1646  */
+#line 1258 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = NULL; }
 
     break;
 
   case 245:
-#line 1248 "perly.y" /* yacc.c:1646  */
+#line 1260 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 246:
-#line 1252 "perly.y" /* yacc.c:1646  */
+#line 1264 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = NULL; }
 
     break;
 
   case 247:
-#line 1254 "perly.y" /* yacc.c:1646  */
+#line 1266 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
 
   case 248:
-#line 1260 "perly.y" /* yacc.c:1646  */
+#line 1272 "perly.y" /* yacc.c:1646  */
     { parser->in_my = 0; (yyval.opval) = my((ps[0].val.opval)); }
 
     break;
 
   case 256:
-#line 1277 "perly.y" /* yacc.c:1646  */
+#line 1289 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newCVREF((ps[-1].val.ival),(ps[0].val.opval)); }
 
     break;
 
   case 257:
-#line 1281 "perly.y" /* yacc.c:1646  */
+#line 1293 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newSVREF((ps[0].val.opval)); }
 
     break;
 
   case 258:
-#line 1285 "perly.y" /* yacc.c:1646  */
+#line 1297 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newAVREF((ps[0].val.opval));
 			  if ((yyval.opval)) (yyval.opval)->op_private |= (ps[-1].val.ival);
 			}
@@ -1904,7 +1916,7 @@ case 2:
     break;
 
   case 259:
-#line 1291 "perly.y" /* yacc.c:1646  */
+#line 1303 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newHVREF((ps[0].val.opval));
 			  if ((yyval.opval)) (yyval.opval)->op_private |= (ps[-1].val.ival);
 			}
@@ -1912,61 +1924,61 @@ case 2:
     break;
 
   case 260:
-#line 1297 "perly.y" /* yacc.c:1646  */
+#line 1309 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newAVREF((ps[0].val.opval)); }
 
     break;
 
   case 261:
-#line 1299 "perly.y" /* yacc.c:1646  */
+#line 1311 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newAVREF((ps[-3].val.opval)); }
 
     break;
 
   case 262:
-#line 1303 "perly.y" /* yacc.c:1646  */
+#line 1315 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newGVREF(0,(ps[0].val.opval)); }
 
     break;
 
   case 264:
-#line 1308 "perly.y" /* yacc.c:1646  */
+#line 1320 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newAVREF((ps[-2].val.opval)); }
 
     break;
 
   case 266:
-#line 1313 "perly.y" /* yacc.c:1646  */
+#line 1325 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newHVREF((ps[-2].val.opval)); }
 
     break;
 
   case 268:
-#line 1318 "perly.y" /* yacc.c:1646  */
+#line 1330 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = newGVREF(0,(ps[-2].val.opval)); }
 
     break;
 
   case 269:
-#line 1323 "perly.y" /* yacc.c:1646  */
+#line 1335 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = scalar((ps[0].val.opval)); }
 
     break;
 
   case 270:
-#line 1325 "perly.y" /* yacc.c:1646  */
+#line 1337 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = scalar((ps[0].val.opval)); }
 
     break;
 
   case 271:
-#line 1327 "perly.y" /* yacc.c:1646  */
+#line 1339 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = op_scope((ps[0].val.opval)); }
 
     break;
 
   case 272:
-#line 1330 "perly.y" /* yacc.c:1646  */
+#line 1342 "perly.y" /* yacc.c:1646  */
     { (yyval.opval) = (ps[0].val.opval); }
 
     break;
@@ -1977,6 +1989,6 @@ case 2:
     
 
 /* Generated from:
- * a8b5527eacb1205d15c8c01acb4a8f99b494e5b453ddd68a2a2e7fca4be3302a perly.y
+ * c44aaa81abd3fc5c53b5aee014f9e6e11ef70a4c8470b767618f5938627ef0e7 perly.y
  * 153cba5d215c1a083a0459c43f4d55c45fd0a7093c197d7247a456dcde21ea53 regen_perly.pl
  * ex: set ro: */
diff --git a/perly.h b/perly.h
index a7e9a43..256d797 100644
--- a/perly.h
+++ b/perly.h
@@ -7,11 +7,11 @@
 #define PERL_BISON_VERSION  30000
 
 #ifdef PERL_CORE
-/* A Bison parser, made by GNU Bison 3.0.2.  */
+/* A Bison parser, made by GNU Bison 3.0.4.  */
 
 /* Bison interface for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -160,7 +160,7 @@ S_is_opval_token(int type) {
 #endif /* PERL_IN_TOKE_C */
 #endif /* PERL_CORE */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE YYSTYPE;
+
 union YYSTYPE
 {
 
@@ -171,6 +171,8 @@ union YYSTYPE
     GV *gvval;
 
 };
+
+typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
 #endif
@@ -181,6 +183,6 @@ int yyparse (void);
 
 
 /* Generated from:
- * a8b5527eacb1205d15c8c01acb4a8f99b494e5b453ddd68a2a2e7fca4be3302a perly.y
+ * c44aaa81abd3fc5c53b5aee014f9e6e11ef70a4c8470b767618f5938627ef0e7 perly.y
  * 153cba5d215c1a083a0459c43f4d55c45fd0a7093c197d7247a456dcde21ea53 regen_perly.pl
  * ex: set ro: */
diff --git a/perly.tab b/perly.tab
index e4065de..fe19874 100644
--- a/perly.tab
+++ b/perly.tab
@@ -83,20 +83,20 @@ static const yytype_uint16 yyrline[] =
      769,   774,   773,   825,   826,   830,   832,   834,   836,   840,
      842,   847,   851,   855,   859,   865,   870,   876,   882,   884,
      887,   886,   897,   898,   902,   906,   909,   914,   919,   922,
-     926,   930,   933,   938,   942,   945,   947,   949,   954,   956,
-     958,   963,   965,   967,   969,   971,   973,   975,   977,   979,
-     981,   983,   988,   990,   993,   995,   997,  1000,  1003,  1014,
-    1017,  1024,  1026,  1028,  1030,  1032,  1035,  1049,  1051,  1055,
-    1056,  1057,  1058,  1059,  1061,  1063,  1065,  1067,  1069,  1071,
-    1073,  1075,  1077,  1079,  1081,  1083,  1085,  1087,  1097,  1107,
-    1117,  1127,  1129,  1131,  1134,  1139,  1143,  1145,  1147,  1149,
-    1152,  1154,  1157,  1159,  1161,  1163,  1165,  1167,  1169,  1171,
-    1173,  1176,  1178,  1180,  1182,  1184,  1186,  1190,  1193,  1192,
-    1205,  1206,  1207,  1212,  1216,  1218,  1220,  1225,  1227,  1230,
-    1232,  1234,  1239,  1241,  1246,  1247,  1252,  1253,  1259,  1263,
-    1264,  1265,  1268,  1269,  1272,  1273,  1276,  1280,  1284,  1290,
-    1296,  1298,  1302,  1306,  1307,  1311,  1312,  1316,  1317,  1322,
-    1324,  1326,  1329
+     926,   930,   936,   944,   951,   957,   959,   961,   966,   968,
+     970,   975,   977,   979,   981,   983,   985,   987,   989,   991,
+     993,   995,  1000,  1002,  1005,  1007,  1009,  1012,  1015,  1026,
+    1029,  1036,  1038,  1040,  1042,  1044,  1047,  1061,  1063,  1067,
+    1068,  1069,  1070,  1071,  1073,  1075,  1077,  1079,  1081,  1083,
+    1085,  1087,  1089,  1091,  1093,  1095,  1097,  1099,  1109,  1119,
+    1129,  1139,  1141,  1143,  1146,  1151,  1155,  1157,  1159,  1161,
+    1164,  1166,  1169,  1171,  1173,  1175,  1177,  1179,  1181,  1183,
+    1185,  1188,  1190,  1192,  1194,  1196,  1198,  1202,  1205,  1204,
+    1217,  1218,  1219,  1224,  1228,  1230,  1232,  1237,  1239,  1242,
+    1244,  1246,  1251,  1253,  1258,  1259,  1264,  1265,  1271,  1275,
+    1276,  1277,  1280,  1281,  1284,  1285,  1288,  1292,  1296,  1302,
+    1308,  1310,  1314,  1318,  1319,  1323,  1324,  1328,  1329,  1334,
+    1336,  1338,  1341
 };
 #endif
 
@@ -1109,6 +1109,6 @@ static const toketypes yy_type_tab[] =
 };
 
 /* Generated from:
- * a8b5527eacb1205d15c8c01acb4a8f99b494e5b453ddd68a2a2e7fca4be3302a perly.y
+ * c44aaa81abd3fc5c53b5aee014f9e6e11ef70a4c8470b767618f5938627ef0e7 perly.y
  * 153cba5d215c1a083a0459c43f4d55c45fd0a7093c197d7247a456dcde21ea53 regen_perly.pl
  * ex: set ro: */
diff --git a/perly.y b/perly.y
index 7d57dea..14d48d6 100644
--- a/perly.y
+++ b/perly.y
@@ -929,19 +929,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 */
diff --git a/t/op/postfixderef.t b/t/op/postfixderef.t
index ba69f06..c2983cf 100644
--- a/t/op/postfixderef.t
+++ b/t/op/postfixderef.t
@@ -16,7 +16,7 @@ BEGIN {
 
 use strict qw(refs subs);
 
-plan(116);
+plan(130);
 
 {
     no strict 'refs';
@@ -365,3 +365,26 @@ is "$_->@{foo}", "foo->7 8 9", '->@{ does not interpolate without feature';
     is "foo$ref->$*bar", "foo plus overload plus bar",
        '"foo $s->$* bar" does concat overloading';
 }
+
+# parsing of {} subscript as subscript rather than block
+{
+    sub ppp { "qqq" }
+    my $h = { ppp => "pp", qqq => "qq", rrr => 7 };
+    is ${$h}{ppp}, "pp";
+    is ${$h}{"rrr"} - 2, 5;
+    my $ar = [$h];
+    is $ar->[0]->{ppp}, "pp";
+    is $ar->[0]->{"rrr"} - 2, 5;
+    is $ar->[0]{ppp}, "pp";
+    is $ar->[0]{"rrr"} - 2, 5;
+    my $hr = {h=>$h};
+    is $hr->{"h"}->{ppp}, "pp";
+    is $hr->{"h"}->{"rrr"} - 2, 5;
+    is $hr->{"h"}{ppp}, "pp";
+    is $hr->{"h"}{"rrr"} - 2, 5;
+    my $cr = sub { $h };
+    is $cr->()->{ppp}, "pp";
+    is $cr->()->{"rrr"} - 2, 5;
+    is $cr->(){ppp}, "pp";
+    is $cr->(){"rrr"} - 2, 5;
+}
-- 
2.13.6