Skip to content

Commit ed115c5

Browse files
authored
Fix computed checks in acorn-optimizer. NFC (#24271)
`.computed` is a property of `MemberExpression`, but in a few cases it was incorrectly checked on `CallExpression`s. This doesn't cause issues in existing tests, mostly noticed as a drive-by fix.
1 parent fb2ea4d commit ed115c5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tools/acorn-optimizer.mjs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,8 @@ function JSDCE(ast, aggressive) {
421421
},
422422
MemberExpression(node, c) {
423423
c(node.object);
424-
// Ignore a property identifier (a.X), but notice a[X] (computed
425-
// is true) and a["X"] (it will be a Literal and not Identifier).
426-
if (node.property.type !== 'Identifier' || node.computed) {
424+
// Ignore a property identifier (a.X), but notice a[X] (computed props).
425+
if (node.computed) {
427426
c(node.property);
428427
}
429428
},
@@ -1206,7 +1205,7 @@ function littleEndianHeap(ast) {
12061205
node.callee.object.type === 'Identifier' &&
12071206
node.callee.object.name === 'Atomics' &&
12081207
node.callee.property.type === 'Identifier' &&
1209-
!node.computed
1208+
!node.callee.computed
12101209
) {
12111210
makeCallExpression(
12121211
node,
@@ -1391,7 +1390,7 @@ function unsignPointers(ast) {
13911390
node.callee.object.type === 'Identifier' &&
13921391
isHeap(node.callee.object.name) &&
13931392
node.callee.property.type === 'Identifier' &&
1394-
!node.computed
1393+
!node.callee.computed
13951394
) {
13961395
// This is a call on HEAP*.?. Specific things we need to fix up are
13971396
// subarray, set, and copyWithin. TODO more?

0 commit comments

Comments
 (0)