temporarily forbid AssignmentExpression destructuring outside of ExpressionStatement

This commit is contained in:
Sebastian McKenzie 2014-11-13 13:40:41 +11:00
parent 751ea7a12c
commit 8ff21b407d
6 changed files with 14 additions and 0 deletions

View File

@ -1,3 +1,7 @@
# 1.12.8
* Temporarily forbid `AssignmentExpression` destructuring outside of `ExpressionStatement`.
# 1.12.7
* Update to latest `acorn-6to5`.

View File

@ -146,6 +146,12 @@ exports.ExpressionStatement = function (node, parent, file, scope) {
return nodes;
};
exports.AssignmentExpression = function (node, parent, file) {
if (parent.type === "ExpressionStatement") return;
if (!t.isPattern(node.left)) return;
throw file.errorWithNode(node, "AssignmentExpression destructuring outside of a ExpressionStatement is forbidden due to current limitations");
};
exports.VariableDeclaration = function (node, parent, file, scope) {
if (t.isForInStatement(parent) || t.isForOfStatement(parent)) return;

View File

@ -0,0 +1 @@
console.log([x] = [123]);

View File

@ -0,0 +1,3 @@
{
"throws": "AssignmentExpression destructuring outside of a ExpressionStatement is forbidden due to current limitations"
}