Skip to content

Commit 7ea06d0

Browse files
committed
Make compound assignment operators (+= etc) fail validation.
1 parent bbb1676 commit 7ea06d0

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

lib/validate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ Vp.expression = function expression(e) {
794794

795795
when({
796796
type: 'AssignmentExpression',
797+
operator: '=',
797798
left: match.var('left', { type: match.some('Identifier', 'MemberExpression') }),
798799
right: match.var('right')
799800
}, function(vars) {

test/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,11 @@ exports.testConditionalExpressionDifferentSubtypes = asmAssert.one(
322322
return (1 ? (2 < 3) : 4)|0;
323323
},
324324
{ pass: true });
325+
326+
exports.testCompoundAssignment = asmAssert.one(
327+
"compound assignment operations such as += are disallowed",
328+
function f() {
329+
var x = 0;
330+
x += 1;
331+
},
332+
{ pass: false });

0 commit comments

Comments
 (0)