diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-09-14 17:23:11 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-09-14 18:24:21 -0700 |
commit | 429a25554a608b64c0ee46c1ffe19bab3718a3c8 (patch) | |
tree | 14715e2179b09d1708fb9b6bf4516187b225cbe5 /perly.tab | |
parent | 61c85d894087ca7f0282600eb64d5af1e7b8e5d4 (diff) | |
download | perl-429a25554a608b64c0ee46c1ffe19bab3718a3c8.tar.gz |
Reduce false positives for @hsh{$s} and @ary[$s] warnings
This resolves tickets #28380 and #114024.
Commit 95a31aad5 did something similar to this for the new %hash{...}
syntax. This commit extends it to @ slices and combines the two
code paths.
The heuristics in toke.c can easily produce false positives. So the
op is flagged as being a candidate for the warning. Then when op.c
has the op tree available, it examines it to see whether the heuristic
may have been a false positive.
This avoids bugs with qw "foo bar baz" and sub calls triggering
the warning.
The source code is no longer available for the warning, so we recon-
struct it from the op tree, skipping the subscript if it is anything
other than a const op.
This means that @hash{$foo} comes out as @hash{...} and @hash{foo} as
@hash{"foo"}. It also meeans that @hash{"]"} is displayed correctly
instead of as @hash{"].
Commit 95a31aad5 also modified the heuristic for %hash{...} to exempt
qw altogether. But it did not exempt it if it was preceded by a tab.
So this commit rectifies that.
This commit also improves the false positive detection by exempting
any ops returning lists that can get past toke.c’s heuristic. I went
through the entire list of ops, but I may have missed some.
Also, @ slices on the lhs of = are exempt, as they change the context
and are hence actually useful.
Diffstat (limited to 'perly.tab')
-rw-r--r-- | perly.tab | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -197,12 +197,12 @@ static const yytype_uint16 yyrline[] = 1030, 1037, 1041, 1045, 1050, 1055, 1060, 1069, 1074, 1079, 1085, 1091, 1102, 1106, 1110, 1122, 1135, 1143, 1155, 1156, 1157, 1158, 1159, 1164, 1168, 1170, 1174, 1179, 1181, 1186, - 1188, 1190, 1192, 1194, 1196, 1198, 1207, 1219, 1230, 1244, - 1246, 1248, 1253, 1266, 1271, 1276, 1280, 1284, 1288, 1292, - 1296, 1300, 1304, 1306, 1309, 1313, 1319, 1321, 1326, 1329, - 1338, 1345, 1344, 1360, 1361, 1362, 1368, 1372, 1380, 1387, - 1392, 1397, 1399, 1401, 1406, 1408, 1413, 1414, 1420, 1424, - 1430, 1436, 1442, 1449, 1455, 1462, 1464, 1466, 1469 + 1188, 1190, 1192, 1194, 1196, 1198, 1210, 1222, 1236, 1250, + 1252, 1254, 1259, 1272, 1277, 1282, 1286, 1290, 1294, 1298, + 1302, 1306, 1310, 1312, 1315, 1319, 1325, 1327, 1332, 1335, + 1344, 1351, 1350, 1366, 1367, 1368, 1374, 1378, 1386, 1393, + 1398, 1403, 1405, 1407, 1412, 1414, 1419, 1420, 1426, 1430, + 1436, 1442, 1449, 1456, 1462, 1469, 1471, 1473, 1476 }; #endif @@ -1123,6 +1123,6 @@ static const toketypes yy_type_tab[] = }; /* Generated from: - * 80609b739b642fa427503886445869dfd47021624a1977b902211b38043ed9f1 perly.y + * 5b290f371f373fb17e073f602c676e436e9d457a1d4db67d192e3cfa0eeb36d7 perly.y * 5c9d2a0262457fe9b70073fc8ad6c188f812f38ad57712b7e2f53daa01b297cc regen_perly.pl * ex: set ro: */ |