-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Description
TypeScript Version: 3.3.0-dev.20190124
Search Terms: async, super, generator, RangeError Maximum call stack size exceeded
Code
Target: ES6
class TestBase {
async foo() {
return true;
}
async *bar() {
yield* [1, 2, 3];
}
}
class TestDerived extends TestBase {
async foo() {
return await super.foo() || true;
}
async *bar() {
yield* super.bar();
}
}Expected behavior:
Compiled to working code.
Actual behavior:
Compiled to code that causes stack overflow:
// <--- helpers are omitted
class TestBase {
foo() {
return __awaiter(this, void 0, void 0, function* () {
return true;
});
}
bar() {
return __asyncGenerator(this, arguments, function* bar_1() {
yield __await(yield* __asyncDelegator(__asyncValues([1, 2, 3])));
});
}
}
class TestDerived extends TestBase {
foo() {
const _super = Object.create(null, {
foo: { get: () => _super.foo }
});
return __awaiter(this, void 0, void 0, function* () {
return (yield _super.foo.call(this)) || true;
});
}
bar() {
const _super = Object.create(null, {
bar: { get: () => _super.bar }
});
return __asyncGenerator(this, arguments, function* bar_2() {
yield __await(yield* __asyncDelegator(__asyncValues(_super.bar.call(this))));
});
}
}Note the generated _super statement contains a call to itself, which will cause RangeError: Maximum call stack size exceeded.
Playground Link:
N/A
Related Issues:
#29325
ionTea, mattetre and AleksueiR
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript