From 782ae7d285d7b87d9b0eb54a6bb14635c9295da2 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Mon, 3 Aug 2015 01:12:09 +0100 Subject: [PATCH] Make compound assignment operators (+= etc) fail validation. --- lib/validate.js | 1 + test/index.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/validate.js b/lib/validate.js index dc95adf..72a2aa1 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -794,6 +794,7 @@ Vp.expression = function expression(e) { when({ type: 'AssignmentExpression', + operator: '=', left: match.var('left', { type: match.some('Identifier', 'MemberExpression') }), right: match.var('right') }, function(vars) { diff --git a/test/index.js b/test/index.js index a787115..6a540b6 100644 --- a/test/index.js +++ b/test/index.js @@ -354,3 +354,11 @@ exports.testForWithoutUpdate = asmAssert.one( } }, { pass: true }); + +exports.testCompoundAssignment = asmAssert.one( + "compound assignment operations such as += are disallowed", + function f() { + var x = 0; + x += 1; + }, + { pass: false });