mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Fix emit for downlevel generated catch variable
This commit is contained in:
@@ -1942,7 +1942,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function substituteExpressionIdentifier(node: Identifier) {
|
||||
if (renamedCatchVariables && renamedCatchVariables.has(node.text)) {
|
||||
if (!isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(node.text)) {
|
||||
const original = getOriginalNode(node);
|
||||
if (isIdentifier(original) && original.parent) {
|
||||
const declaration = resolver.getReferencedValueDeclaration(original);
|
||||
@@ -2108,17 +2108,24 @@ namespace ts {
|
||||
function beginCatchBlock(variable: VariableDeclaration): void {
|
||||
Debug.assert(peekBlockKind() === CodeBlockKind.Exception);
|
||||
|
||||
const text = (<Identifier>variable.name).text;
|
||||
const name = declareLocal(text);
|
||||
|
||||
if (!renamedCatchVariables) {
|
||||
renamedCatchVariables = createMap<boolean>();
|
||||
renamedCatchVariableDeclarations = [];
|
||||
context.enableSubstitution(SyntaxKind.Identifier);
|
||||
// generated identifiers should already be unique within a file
|
||||
let name: Identifier;
|
||||
if (isGeneratedIdentifier(variable.name)) {
|
||||
name = variable.name;
|
||||
hoistVariableDeclaration(variable.name);
|
||||
}
|
||||
else {
|
||||
const text = (<Identifier>variable.name).text;
|
||||
name = declareLocal(text);
|
||||
if (!renamedCatchVariables) {
|
||||
renamedCatchVariables = createMap<boolean>();
|
||||
renamedCatchVariableDeclarations = [];
|
||||
context.enableSubstitution(SyntaxKind.Identifier);
|
||||
}
|
||||
|
||||
renamedCatchVariables.set(text, true);
|
||||
renamedCatchVariableDeclarations[getOriginalNodeId(variable)] = name;
|
||||
renamedCatchVariables.set(text, true);
|
||||
renamedCatchVariableDeclarations[getOriginalNodeId(variable)] = name;
|
||||
}
|
||||
|
||||
const exception = <ExceptionBlock>peekBlock();
|
||||
Debug.assert(exception.state < ExceptionBlockState.Catch);
|
||||
|
||||
@@ -68,36 +68,36 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||
};
|
||||
function f1() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var y, y_1, y_1_1, x, _a, e_1, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
var y, y_1, y_1_1, x, e_1_1, e_1, _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_c.trys.push([0, 6, 7, 12]);
|
||||
_b.trys.push([0, 6, 7, 12]);
|
||||
y_1 = __asyncValues(y);
|
||||
return [4 /*yield*/, y_1.next()];
|
||||
case 1:
|
||||
y_1_1 = _c.sent();
|
||||
_c.label = 2;
|
||||
y_1_1 = _b.sent();
|
||||
_b.label = 2;
|
||||
case 2:
|
||||
if (!!y_1_1.done) return [3 /*break*/, 5];
|
||||
x = y_1_1.value;
|
||||
_c.label = 3;
|
||||
_b.label = 3;
|
||||
case 3: return [4 /*yield*/, y_1.next()];
|
||||
case 4:
|
||||
y_1_1 = _c.sent();
|
||||
y_1_1 = _b.sent();
|
||||
return [3 /*break*/, 2];
|
||||
case 5: return [3 /*break*/, 12];
|
||||
case 6:
|
||||
_a = _c.sent();
|
||||
e_1_1 = _b.sent();
|
||||
e_1 = { error: e_1_1 };
|
||||
return [3 /*break*/, 12];
|
||||
case 7:
|
||||
_c.trys.push([7, , 10, 11]);
|
||||
if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9];
|
||||
return [4 /*yield*/, _b.call(y_1)];
|
||||
_b.trys.push([7, , 10, 11]);
|
||||
if (!(y_1_1 && !y_1_1.done && (_a = y_1.return))) return [3 /*break*/, 9];
|
||||
return [4 /*yield*/, _a.call(y_1)];
|
||||
case 8:
|
||||
_c.sent();
|
||||
_c.label = 9;
|
||||
_b.sent();
|
||||
_b.label = 9;
|
||||
case 9: return [3 /*break*/, 11];
|
||||
case 10:
|
||||
if (e_1) throw e_1.error;
|
||||
@@ -151,36 +151,36 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||
};
|
||||
function f2() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var x, y, y_1, y_1_1, _a, e_1, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
var x, y, y_1, y_1_1, e_1_1, e_1, _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_c.trys.push([0, 6, 7, 12]);
|
||||
_b.trys.push([0, 6, 7, 12]);
|
||||
y_1 = __asyncValues(y);
|
||||
return [4 /*yield*/, y_1.next()];
|
||||
case 1:
|
||||
y_1_1 = _c.sent();
|
||||
_c.label = 2;
|
||||
y_1_1 = _b.sent();
|
||||
_b.label = 2;
|
||||
case 2:
|
||||
if (!!y_1_1.done) return [3 /*break*/, 5];
|
||||
x = y_1_1.value;
|
||||
_c.label = 3;
|
||||
_b.label = 3;
|
||||
case 3: return [4 /*yield*/, y_1.next()];
|
||||
case 4:
|
||||
y_1_1 = _c.sent();
|
||||
y_1_1 = _b.sent();
|
||||
return [3 /*break*/, 2];
|
||||
case 5: return [3 /*break*/, 12];
|
||||
case 6:
|
||||
_a = _c.sent();
|
||||
e_1_1 = _b.sent();
|
||||
e_1 = { error: e_1_1 };
|
||||
return [3 /*break*/, 12];
|
||||
case 7:
|
||||
_c.trys.push([7, , 10, 11]);
|
||||
if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9];
|
||||
return [4 /*yield*/, _b.call(y_1)];
|
||||
_b.trys.push([7, , 10, 11]);
|
||||
if (!(y_1_1 && !y_1_1.done && (_a = y_1.return))) return [3 /*break*/, 9];
|
||||
return [4 /*yield*/, _a.call(y_1)];
|
||||
case 8:
|
||||
_c.sent();
|
||||
_c.label = 9;
|
||||
_b.sent();
|
||||
_b.label = 9;
|
||||
case 9: return [3 /*break*/, 11];
|
||||
case 10:
|
||||
if (e_1) throw e_1.error;
|
||||
@@ -239,36 +239,36 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
|
||||
};
|
||||
function f3() {
|
||||
return __asyncGenerator(this, arguments, function f3_1() {
|
||||
var y, y_1, y_1_1, x, _a, e_1, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
var y, y_1, y_1_1, x, e_1_1, e_1, _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_c.trys.push([0, 6, 7, 12]);
|
||||
_b.trys.push([0, 6, 7, 12]);
|
||||
y_1 = __asyncValues(y);
|
||||
return [4 /*yield*/, ["await", y_1.next()]];
|
||||
case 1:
|
||||
y_1_1 = _c.sent();
|
||||
_c.label = 2;
|
||||
y_1_1 = _b.sent();
|
||||
_b.label = 2;
|
||||
case 2:
|
||||
if (!!y_1_1.done) return [3 /*break*/, 5];
|
||||
x = y_1_1.value;
|
||||
_c.label = 3;
|
||||
_b.label = 3;
|
||||
case 3: return [4 /*yield*/, ["await", y_1.next()]];
|
||||
case 4:
|
||||
y_1_1 = _c.sent();
|
||||
y_1_1 = _b.sent();
|
||||
return [3 /*break*/, 2];
|
||||
case 5: return [3 /*break*/, 12];
|
||||
case 6:
|
||||
_a = _c.sent();
|
||||
e_1_1 = _b.sent();
|
||||
e_1 = { error: e_1_1 };
|
||||
return [3 /*break*/, 12];
|
||||
case 7:
|
||||
_c.trys.push([7, , 10, 11]);
|
||||
if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9];
|
||||
return [4 /*yield*/, ["await", _b.call(y_1)]];
|
||||
_b.trys.push([7, , 10, 11]);
|
||||
if (!(y_1_1 && !y_1_1.done && (_a = y_1.return))) return [3 /*break*/, 9];
|
||||
return [4 /*yield*/, ["await", _a.call(y_1)]];
|
||||
case 8:
|
||||
_c.sent();
|
||||
_c.label = 9;
|
||||
_b.sent();
|
||||
_b.label = 9;
|
||||
case 9: return [3 /*break*/, 11];
|
||||
case 10:
|
||||
if (e_1) throw e_1.error;
|
||||
@@ -327,36 +327,36 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
|
||||
};
|
||||
function f4() {
|
||||
return __asyncGenerator(this, arguments, function f4_1() {
|
||||
var x, y, y_1, y_1_1, _a, e_1, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
var x, y, y_1, y_1_1, e_1_1, e_1, _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_c.trys.push([0, 6, 7, 12]);
|
||||
_b.trys.push([0, 6, 7, 12]);
|
||||
y_1 = __asyncValues(y);
|
||||
return [4 /*yield*/, ["await", y_1.next()]];
|
||||
case 1:
|
||||
y_1_1 = _c.sent();
|
||||
_c.label = 2;
|
||||
y_1_1 = _b.sent();
|
||||
_b.label = 2;
|
||||
case 2:
|
||||
if (!!y_1_1.done) return [3 /*break*/, 5];
|
||||
x = y_1_1.value;
|
||||
_c.label = 3;
|
||||
_b.label = 3;
|
||||
case 3: return [4 /*yield*/, ["await", y_1.next()]];
|
||||
case 4:
|
||||
y_1_1 = _c.sent();
|
||||
y_1_1 = _b.sent();
|
||||
return [3 /*break*/, 2];
|
||||
case 5: return [3 /*break*/, 12];
|
||||
case 6:
|
||||
_a = _c.sent();
|
||||
e_1_1 = _b.sent();
|
||||
e_1 = { error: e_1_1 };
|
||||
return [3 /*break*/, 12];
|
||||
case 7:
|
||||
_c.trys.push([7, , 10, 11]);
|
||||
if (!(y_1_1 && !y_1_1.done && (_b = y_1.return))) return [3 /*break*/, 9];
|
||||
return [4 /*yield*/, ["await", _b.call(y_1)]];
|
||||
_b.trys.push([7, , 10, 11]);
|
||||
if (!(y_1_1 && !y_1_1.done && (_a = y_1.return))) return [3 /*break*/, 9];
|
||||
return [4 /*yield*/, ["await", _a.call(y_1)]];
|
||||
case 8:
|
||||
_c.sent();
|
||||
_c.label = 9;
|
||||
_b.sent();
|
||||
_b.label = 9;
|
||||
case 9: return [3 /*break*/, 11];
|
||||
case 10:
|
||||
if (e_1) throw e_1.error;
|
||||
|
||||
Reference in New Issue
Block a user