add back specNoForInOfAssignment transformer

This commit is contained in:
Sebastian McKenzie
2015-01-07 18:30:48 +11:00
parent bf24a0d6b5
commit cd23e500a1
7 changed files with 27 additions and 3 deletions

View File

@@ -39,6 +39,8 @@ transform.moduleFormatters = {
};
_.each({
specNoForInOfAssignment: require("./transformers/spec-no-for-in-of-assignment"),
// playground
methodBinding: require("./transformers/playground-method-binding"),
memoizationOperator: require("./transformers/playground-memoization-operator"),

View File

@@ -0,0 +1,10 @@
var t = require("../../types");
exports.ForInStatement =
exports.ForOfStatement = function (node, parent, file) {
var left = node.left;
if (t.isVariableDeclaration(left)) {
var declar = left.declarations[0];
if (declar.init) throw file.errorWithNode(declar, "No assignments allowed in for-in/of head");
}
};

View File

@@ -146,10 +146,10 @@ exports.template = function (name, nodes, keepExpression) {
var node = template.body[0];
if (!keepExpression && t.isExpressionStatement(node)) {
node = node.expression;
return node.expression;
} else {
return node;
}
return node;
};
exports.codeFrame = function (lines, lineNumber, colNumber) {

View File

@@ -0,0 +1,3 @@
for (var i = 0 in obj) {
}

View File

@@ -0,0 +1,3 @@
{
"throws": "No assignments allowed in for-in/of head"
}

View File

@@ -0,0 +1,3 @@
for (var i = 0 of obj) {
}

View File

@@ -0,0 +1,3 @@
{
"throws": "No assignments allowed in for-in/of head"
}