in src/parser.ts [1606:1667]
reinterpretAsCoverFormalsList(expr) {
let params = [expr];
let options;
let asyncArrow = false;
switch (expr.type) {
case Syntax.Identifier:
break;
case ArrowParameterPlaceHolder:
params = expr.params;
asyncArrow = expr.async;
break;
default:
return null;
}
options = {
simple: true,
paramSet: {}
};
for (let i = 0; i < params.length; ++i) {
const param = params[i];
if (param.type === Syntax.AssignmentPattern) {
if (param.right.type === Syntax.YieldExpression) {
if (param.right.argument) {
this.throwUnexpectedToken(this.lookahead);
}
param.right.type = Syntax.Identifier;
param.right.name = 'yield';
delete param.right.argument;
delete param.right.delegate;
}
} else if (asyncArrow && param.type === Syntax.Identifier && param.name === 'await') {
this.throwUnexpectedToken(this.lookahead);
}
this.checkPatternParam(options, param);
params[i] = param;
}
if (this.context.strict || !this.context.allowYield) {
for (let i = 0; i < params.length; ++i) {
const param = params[i];
if (param.type === Syntax.YieldExpression) {
this.throwUnexpectedToken(this.lookahead);
}
}
}
if (options.message === Messages.StrictParamDupe) {
const token = this.context.strict ? options.stricted : options.firstRestricted;
this.throwUnexpectedToken(token, options.message);
}
return {
simple: options.simple,
params: params,
stricted: options.stricted,
firstRestricted: options.firstRestricted,
message: options.message
};
}