Fix argument list for new containing yield
This commit is contained in:
parent
73ada7a78d
commit
e389e08f71
|
@ -946,7 +946,7 @@ namespace ts {
|
|||
* @param node The node to visit.
|
||||
*/
|
||||
function visitArrayLiteralExpression(node: ArrayLiteralExpression) {
|
||||
return visitElements(node.elements, node.multiLine);
|
||||
return visitElements(node.elements, /*leadingElement*/ undefined, /*location*/ undefined, node.multiLine);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -956,7 +956,7 @@ namespace ts {
|
|||
* @param elements The elements to visit.
|
||||
* @param multiLine Whether array literals created should be emitted on multiple lines.
|
||||
*/
|
||||
function visitElements(elements: NodeArray<Expression>, _multiLine?: boolean) {
|
||||
function visitElements(elements: NodeArray<Expression>, leadingElement?: Expression, location?: TextRange, multiLine?: boolean) {
|
||||
// [source]
|
||||
// ar = [1, yield, 2];
|
||||
//
|
||||
|
@ -971,18 +971,22 @@ namespace ts {
|
|||
const temp = declareLocal();
|
||||
let hasAssignedTemp = false;
|
||||
if (numInitialElements > 0) {
|
||||
const initialElements = visitNodes(elements, visitor, isExpression, 0, numInitialElements);
|
||||
emitAssignment(temp,
|
||||
createArrayLiteral(
|
||||
visitNodes(elements, visitor, isExpression, 0, numInitialElements)
|
||||
leadingElement
|
||||
? [leadingElement, ...initialElements]
|
||||
: initialElements
|
||||
)
|
||||
);
|
||||
leadingElement = undefined;
|
||||
hasAssignedTemp = true;
|
||||
}
|
||||
|
||||
const expressions = reduceLeft(elements, reduceElement, <Expression[]>[], numInitialElements);
|
||||
return hasAssignedTemp
|
||||
? createArrayConcat(temp, [createArrayLiteral(expressions)])
|
||||
: createArrayLiteral(expressions);
|
||||
? createArrayConcat(temp, [createArrayLiteral(expressions, /*location*/ undefined, multiLine)])
|
||||
: createArrayLiteral(leadingElement ? [leadingElement, ...expressions] : expressions, location, multiLine);
|
||||
|
||||
function reduceElement(expressions: Expression[], element: Expression) {
|
||||
if (containsYield(element) && expressions.length > 0) {
|
||||
|
@ -991,11 +995,16 @@ namespace ts {
|
|||
hasAssignedTemp
|
||||
? createArrayConcat(
|
||||
temp,
|
||||
[createArrayLiteral(expressions)]
|
||||
[createArrayLiteral(expressions, /*location*/ undefined, multiLine)]
|
||||
)
|
||||
: createArrayLiteral(
|
||||
leadingElement ? [leadingElement, ...expressions] : expressions,
|
||||
/*location*/ undefined,
|
||||
multiLine
|
||||
)
|
||||
: createArrayLiteral(expressions)
|
||||
);
|
||||
hasAssignedTemp = true;
|
||||
leadingElement = undefined;
|
||||
expressions = [];
|
||||
}
|
||||
|
||||
|
@ -1131,7 +1140,10 @@ namespace ts {
|
|||
createFunctionApply(
|
||||
cacheExpression(visitNode(target, visitor, isExpression)),
|
||||
thisArg,
|
||||
visitElements(node.arguments)
|
||||
visitElements(
|
||||
node.arguments,
|
||||
/*leadingElement*/ createVoidZero()
|
||||
)
|
||||
),
|
||||
/*typeArguments*/ undefined,
|
||||
[],
|
||||
|
|
|
@ -119,7 +119,7 @@ function newExpression2() {
|
|||
_a = x.bind;
|
||||
return [4 /*yield*/, y];
|
||||
case 1:
|
||||
new (_a.apply(x, [_c.sent(), z]))();
|
||||
new (_a.apply(x, [void 0, _c.sent(), z]))();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
|
@ -132,7 +132,7 @@ function newExpression3() {
|
|||
switch (_c.label) {
|
||||
case 0:
|
||||
_a = x.bind;
|
||||
_b = [y];
|
||||
_b = [void 0, y];
|
||||
return [4 /*yield*/, z];
|
||||
case 1:
|
||||
new (_a.apply(x, _b.concat([_c.sent()])))();
|
||||
|
@ -280,7 +280,7 @@ function newExpression13() {
|
|||
_b = (_a = x.a).bind;
|
||||
return [4 /*yield*/, y];
|
||||
case 1:
|
||||
new (_b.apply(_a, [_d.sent(), z]))();
|
||||
new (_b.apply(_a, [void 0, _d.sent(), z]))();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
|
@ -293,7 +293,7 @@ function newExpression14() {
|
|||
switch (_d.label) {
|
||||
case 0:
|
||||
_b = (_a = x.a).bind;
|
||||
_c = [y];
|
||||
_c = [void 0, y];
|
||||
return [4 /*yield*/, z];
|
||||
case 1:
|
||||
new (_b.apply(_a, _c.concat([_d.sent()])))();
|
||||
|
@ -362,7 +362,7 @@ function newExpression19() {
|
|||
_b = (_a = x[a]).bind;
|
||||
return [4 /*yield*/, y];
|
||||
case 1:
|
||||
new (_b.apply(_a, [_d.sent(), z]))();
|
||||
new (_b.apply(_a, [void 0, _d.sent(), z]))();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
|
@ -375,7 +375,7 @@ function newExpression20() {
|
|||
switch (_d.label) {
|
||||
case 0:
|
||||
_b = (_a = x[a]).bind;
|
||||
_c = [y];
|
||||
_c = [void 0, y];
|
||||
return [4 /*yield*/, z];
|
||||
case 1:
|
||||
new (_b.apply(_a, _c.concat([_d.sent()])))();
|
||||
|
|
Loading…
Reference in a new issue