Revert "Distinguish between ternary's : and arrow fn's return type (#573)"

This reverts commit a9a55fbd3f.
This commit is contained in:
Henry Zhu
2017-06-27 15:58:57 -04:00
parent a9a55fbd3f
commit 88298536c5
15 changed files with 10 additions and 6840 deletions

View File

@@ -1081,15 +1081,11 @@ export default class ExpressionParser extends LValParser {
parseArrowExpression(node: N.ArrowFunctionExpression, params: N.Expression[], isAsync?: boolean): N.ArrowFunctionExpression {
this.initFunction(node, isAsync);
this.setArrowFunctionParameters(node, params);
node.params = this.toAssignableList(params, true, "arrow function parameters");
this.parseFunctionBody(node, true);
return this.finishNode(node, "ArrowFunctionExpression");
}
setArrowFunctionParameters(node: N.ArrowFunctionExpression, params: N.Expression[]): N.ArrowFunctionExpression {
node.params = this.toAssignableList(params, true, "arrow function parameters");
}
isStrictBody(node: { body: N.BlockStatement }, isExpression?: boolean): boolean {
if (!isExpression && node.body.directives.length) {
for (const directive of node.body.directives) {
@@ -1124,19 +1120,12 @@ export default class ExpressionParser extends LValParser {
}
this.state.inAsync = oldInAsync;
this.checkFunctionNameAndParams(node, allowExpression);
}
checkFunctionNameAndParams(
node: N.Function,
isArrowFunction?: boolean
): void {
// If this is a strict mode function, verify that argument names
// are not repeated, and it does not try to bind the words `eval`
// or `arguments`.
const isStrict = this.isStrictBody(node, node.expression);
// Also check for arrow functions
const checkLVal = this.state.strict || isStrict || isArrowFunction;
const isStrict = this.isStrictBody(node, isExpression);
// Also check when allowExpression === true for arrow functions
const checkLVal = this.state.strict || allowExpression || isStrict;
if (isStrict && node.id && node.id.type === "Identifier" && node.id.name === "yield") {
this.raise(node.id.start, "Binding yield in strict mode");