From 7c9bba40e6b10987d930dfc8cba9b3e4f1229075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Segersv=C3=A4rd?= Date: Thu, 16 Jul 2015 18:21:21 +0200 Subject: [PATCH] Added a call to checkForReads in computed member expressions. Tests pass. --- src/Statement.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Statement.js b/src/Statement.js index 6f0b5b6..c2cde6e 100644 --- a/src/Statement.js +++ b/src/Statement.js @@ -175,10 +175,24 @@ export default class Statement { } checkForWrites ( scope, node ) { + const parent = node; + const addNode = ( node, isAssignment ) => { let depth = 0; // determine whether we're illegally modifying a binding or namespace while ( node.type === 'MemberExpression' ) { + + // In a situation like that below, make sure the assignments + // depend on `a` and `b`. + // + // var a = 1, b = 0; + // + // arr[a] = arr[b] = true; + // + if ( node.computed ) { + this.checkForReads( scope, node.property, parent, true ); + } + node = node.object; depth += 1; }